Re: Compiling Linux kernel into a build directory

2021-04-02 Thread Randy Dunlap
On 4/2/21 11:29 AM, James Courtier-Dutton wrote:
> Hi,
> 
> Currently, when one builds the linux kernel, it places .o files all
> over the source code tree.
> Is there a way to have the linux kernel build, but place all the .o
> files into a separate build folder?
> Similar to how cmake or ninja work when building C source code.
> 
> One possible advantage of this approach is one can then put the build
> folder on a ram disk / tmpfs   and be able to compile and test much
> quicker.

That has been available for quite a long time now.
Just use "O=somebuilddir" on the make command line.

$ mkdir build
$ make O=build allnoconfig
$ make O=build all

AFAIK 'somebuilddir' can be a relative path (that's what
I use, in the kernel source tree) or an absolute path,
like O=/tmp/buildit .

>From kernel Makefile "help":
@echo  '  make O=dir [targets] Locate all output files in "dir", 
including .config'


and from kernel Makefile comments:

# Kbuild will save output files in the current working directory.
# This does not need to match to the root of the kernel source tree.
#
# For example, you can do this:
#
#  cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
#
# If you want to save output files in a different location, there are
# two syntaxes to specify it.
#
# 1) O=
# Use "make O=dir/to/store/output/files/"
#
# 2) Set KBUILD_OUTPUT
# Set the environment variable KBUILD_OUTPUT to point to the output directory.
# export KBUILD_OUTPUT=dir/to/store/output/files/; make
#
# The O= assignment takes precedence over the KBUILD_OUTPUT environment
# variable.


HTH.
-- 
~Randy



Re: [PATCH V2 3/5] arm64: dts: qcom: pmk8350: Add PMIC peripherals for pmk8350

2021-04-02 Thread Matthias Kaehlcke
On Thu, Apr 01, 2021 at 02:43:14PM +0530, satya priya wrote:
> subject: arm64: dts: qcom: pmk8350: Add PMIC peripherals for pmk8350

same nit as for 1/5: maybe just 'arm64: dts: qcom: Add pml7350 support/.dtsi'
or similar since this adds the initial .dtsi for the pmk8350?

> Add PON, GPIO, RTC and other PMIC infra modules support for pmk8350.

nit: also mention that it adds the pmk8350 .dtsi in the first place.

> Signed-off-by: satya priya 
> ---
>  arch/arm64/boot/dts/qcom/pmk8350.dtsi | 100 
> ++
>  1 file changed, 100 insertions(+)
>  create mode 100644 arch/arm64/boot/dts/qcom/pmk8350.dtsi
> 
> diff --git a/arch/arm64/boot/dts/qcom/pmk8350.dtsi 
> b/arch/arm64/boot/dts/qcom/pmk8350.dtsi
> new file mode 100644
> index 000..13631f2
> --- /dev/null
> +++ b/arch/arm64/boot/dts/qcom/pmk8350.dtsi
> @@ -0,0 +1,100 @@
> +// SPDX-License-Identifier: BSD-3-Clause
> +// Copyright (c) 2021, The Linux Foundation. All rights reserved.
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +_bus {
> + pmk8350: pmic@0 {
> + compatible = "qcom,pmk8350", "qcom,spmi-pmic";

Please provide a link to the binding if it has been sent.

> + reg = <0x0 SPMI_USID>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + pmk8350_pon: pon@1300 {
> + compatible = "qcom,pm8998-pon";
> + reg = <0x1300>;
> +
> + pwrkey {
> + compatible = "qcom,pmk8350-pwrkey";
> + interrupts = <0x0 0x13 0x7 IRQ_TYPE_EDGE_BOTH>;
> + linux,code = ;
> + };
> +
> + resin {
> + compatible = "qcom,pmk8350-resin";
> + interrupts = <0x0 0x13 0x6 IRQ_TYPE_EDGE_BOTH>;
> + linux,code = ;
> + };

Is the usage of this keys really universal across different boards?

At least for the volume down key for most PMICs the config is in the
board file, which seems to make more sense.

> + };
> +
> + pmk8350_vadc: adc@3100 {
> + compatible = "qcom,spmi-adc7";
> + reg = <0x3100>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> + interrupts = <0x0 0x31 0x0 IRQ_TYPE_EDGE_RISING>;
> + interrupt-names = "eoc-int-en-set";
> + #io-channel-cells = <1>;
> + io-channel-ranges;
> +
> + pmk8350_die_temp {
> + reg = ;
> + label = "pmk8350_die_temp";
> + qcom,pre-scaling = <1 1>;
> + };
> +
> + pm8350_die_temp {
> + reg = ;
> + label = "pm8350_die_temp";
> + qcom,pre-scaling = <1 1>;
> + };

nit: I think this should be 'alphabetical' order, so 'pm8350_die_temp' should
be before 'pmk8350_die_temp'.

> +
> + pmr735a_die_temp {
> + reg = ;
> + label = "pmr735a_die_temp";
> + qcom,pre-scaling = <1 1>;
> + };
> +
> + pmr735b_die_temp {
> + reg = ;
> + label = "pmr735b_die_temp";
> + qcom,pre-scaling = <1 1>;
> + };

Is it guaranteed that a board with the pmk8350 will always have the
other 3 PMICs?

> + };
> +
> + pmk8350_adc_tm: adc-tm@3400 {
> + compatible = "qcom,adc-tm7";
> + reg = <0x3400>;
> + interrupts = <0x0 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
> + interrupt-names = "threshold";
> + #address-cells = <1>;
> + #size-cells = <0>;
> + #thermal-sensor-cells = <1>;
> + status = "disabled";
> + };
> +
> + pmk8350_gpios: gpios@b000 {
> + compatible = "qcom,pmk8350-gpio", "qcom,spmi-gpio";
> + reg = <0xb000>;
> + gpio-controller;
> + gpio-ranges = <_gpios 0 0 4>;
> + #gpio-cells = <2>;
> + interrupt-controller;
> + #interrupt-cells = <2>;
> + };
> +
> + pmk8350_rtc: rtc@6100 {

nit: nodes should be ordered by address, hence 'rtc@6100' should be before
'gpios@b000'.

> + compatible = "qcom,pmk8350-rtc";
> + reg = <0x6100>, <0x6200>;
> + reg-names = "rtc", 

Re: [PATCH] qemu_fw_cfg: Make fw_cfg_rev_attr a proper kobj_attribute

2021-04-02 Thread Sedat Dilek
On Fri, Apr 2, 2021 at 8:31 PM Nathan Chancellor  wrote:
>
> On Fri, Apr 02, 2021 at 11:25:42AM -0700, Kees Cook wrote:
> > On Fri, Apr 02, 2021 at 08:42:07AM +0200, Sedat Dilek wrote:
> > > On Thu, Feb 25, 2021 at 10:25 PM Kees Cook  wrote:
> > > >
> > > > On Thu, 11 Feb 2021 12:42:58 -0700, Nathan Chancellor wrote:
> > > > > fw_cfg_showrev() is called by an indirect call in kobj_attr_show(),
> > > > > which violates clang's CFI checking because fw_cfg_showrev()'s second
> > > > > parameter is 'struct attribute', whereas the ->show() member of 
> > > > > 'struct
> > > > > kobj_structure' expects the second parameter to be of type 'struct
> > > > > kobj_attribute'.
> > > > >
> > > > > $ cat /sys/firmware/qemu_fw_cfg/rev
> > > > > 3
> > > > >
> > > > > [...]
> > > >
> > > > Applied to kspp/cfi/cleanups, thanks!
> > > >
> > > > [1/1] qemu_fw_cfg: Make fw_cfg_rev_attr a proper kobj_attribute
> > > >   https://git.kernel.org/kees/c/f5c4679d6c49
> > > >
> > >
> > > I have queued this up in my custom patchset
> > > (for-5.12/kspp-cfi-cleanups-20210225).
> > >
> > > What is the plan to get this upstream?
> >
> > I haven't sent it to Linus yet -- I was expecting to batch more of these
> > and send them for v5.13. (But if the kvm folks snag it, that's good
> > too.)
>
> I am going to be putting the CFI series through its paces on both arm64
> and x86_64 over the next week or so on several different machines (in
> fact, I am writing up a report right now) so I will probably have some
> more of these as I find them.
>

This was just a friendly ping.

Sami has sent some patches which I reported in the early stage of
clang-cfi (x86-64) through subtree maintainers.
It's up to you Nathan or kvm folks.

Upstreamed patches means to me a RDC-ed custom patchset.

- Sedat -


Re: [PATCH RESEND 0/3] x86/sgx: eextend ioctl

2021-04-02 Thread Dave Hansen
On 4/2/21 11:31 AM, Jethro Beekman wrote:
> On 2021-04-02 17:53, Dave Hansen wrote:
>> On 4/2/21 1:38 AM, Jethro Beekman wrote:
 So, we're talking here about pages that have been EEADDED, but for
 which we do not want to include the entire contents of the page?
 Do these contents always include the beginning of the page, or can
 the holes be anywhere?
>>> Holes can be anywhere, and EEXTEND calls need not be sequential in
>>> memory address or even relate to the most recently EADDed page.
>>
>> I think you're referring to the SGX architecture itself here.  The
>> architecture permits this, right?
> 
> Yes.
> 
>> But, why would an enclave loader application ever do this? 
> 
> e.g. to save space

How does this save space, exactly?  What space does it save?

Let's say I want to add 4352 bytes of data to an enclave.  Today, I have
to page-align the beginning and end of that 4352 bytes, and call the add
ioctl() to add the two resulting pages.  It consumes two EPC pages.

With EEXTEND, if I want to add the data, I only need to page-align the
beginning of the data.  I call add_page on the first page, then eextend
on the 256 bytes.  It consumes two EPC pages.

I guess you can argue that this saves padding out the second page, which
would *theoretically* temporarily eat up one extra page of non-enclave
memory and the cost of a 256-byte memcpy.

>> Is this something we want to support in Linux?
> 
> Why not? Is there a good reason to not fully support this part of the
> CPU architecture?

We don't blindly support CPU features in Linux.  They need to do
something *useful*.  I'm still missing what this does which is useful.

Does any actual, real-world enclave want this functionality?  Why?

P.S. There are plenty of things you can do with the SGX architecture
that we probably won't ever implement in Linux.


Re: [PATCH 14/16] staging: rtl8723bs: remove all RT_TRACE logs in core/rtw_wlan_util.c

2021-04-02 Thread Joe Perches
On Fri, 2021-04-02 at 19:40 +0200, Fabio Aiuto wrote:
> On Fri, Apr 02, 2021 at 08:20:17AM -0700, Joe Perches wrote:
> > On Fri, 2021-04-02 at 14:51 +0200, Fabio Aiuto wrote:
> > > On Fri, Apr 02, 2021 at 03:37:57AM -0700, Joe Perches wrote:
> > > > On Fri, 2021-04-02 at 12:01 +0200, Fabio Aiuto wrote:
> > > > > remove all RT_TRACE logs
> > > > > 
> > > > > fix patch-related checkpatch issues
[]
> > > > Lastly, another suggestion would be to just submit a single patch
> > > > removing _ALL_ the RT_TRACE uses not intermixing various other cleanups
> > > > with the series and then do those other cleanups.
> > > > 
> > > > Using a coccinelle script like:
> > > > 
> > > > $ cat RT_TRACE.cocci
> > > > @@
> > > > expression a, b, c;
> > > > @@
> > > > 
> > > > -   RT_TRACE(a, b, (c));
> > > > 
> > > > $ spatch -sp-file RT_TRACE.cocci drivers/staging/rtl8723bs/
> > > > 
> > > > And then clean up the various bits you think are inappropriately done.
[]
> > > thank you Joe, I tried with (RT_TRACE.cocci in parent folder)
> > > 
> > > user@host:~/src/git/kernels/staging$ spatch -sp-file ../RT_TRACE.cocci 
> > > drivers/staging/rtl8723bs/
> > > init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
> > > 0 files match
> > 
> > Likely you are running the script on the tree after you have
> > applied all your patches.
> > 
> > Try running the cocci script on a fresh copy of -next.
> > 
> > Using the script and adding the script in the commit message helps
> > others to verify that the changes you make do not have any other effect.
> > 
> > $ cat RT_TRACE.cocci
> > @@
> > expression a, b, c;
> > @@
> > 
> > -   RT_TRACE(a, b, (c));
> > 
> > $ git checkout next-20210401
> > $ spatch -sp-file RT_TRACE.cocci --in-place --no-show-diff --very-quiet 
> > drivers/staging/rtl8723bs/
> > 31 files match
> > $ git diff --stat -p
> >  drivers/staging/rtl8723bs/core/rtw_cmd.c  |  34 +--
[]
> >  28 files changed, 19 insertions(+), 935 deletions(-)
[]
> thank you Joe, this mail is so precious ;)

I'm not quite sure what you mean by that but you quoted
nearly 200k of the previous email.

Please remember to trim your replies.




Re: [PATCH] riscv: Bump COMMAND_LINE_SIZE value to 1024

2021-04-02 Thread Maciej W. Rozycki
On Fri, 2 Apr 2021, David Abdurachmanov wrote:

> > > >  This macro is exported as a part of the user API so it must not depend 
> > > > on
> > > > Kconfig.  Also changing it (rather than say adding COMMAND_LINE_SIZE_V2 
> > > > or
> > > > switching to an entirely new data object that has its dimension set in a
> > > > different way) requires careful evaluation as external binaries have and
> > > > will have the value it expands to compiled in, so it's a part of the ABI
> > > > too.
> > >
> > > Thanks, I didn't realize this was part of the user BI.  In that case we
> > > really can't chage it, so we'll have to sort out some other way do fix
> > > whatever is going on.
> > >
> > > I've dropped this from fixes.
> >
> > Does increasing COMMAND_LINE_SIZE break user-space binaries? I would
> > expect it to work the same way as adding new enum values, or adding
> > fields at the end of versioned structs, etc.
> > I would assume the old bootloaders/etc will only support up to the
> > old, smaller max command line size, while the kernel will support
> > larger command line size, which is fine.
> > However, if something copies /proc/cmdline into a fixed-size buffer
> > and expects that to work, that will break... that's quite unfortunate
> > user-space code... is it what we afraid of?
> >
> > Alternatively, could expose the same COMMAND_LINE_SIZE, but internally
> > support a larger command line?
> 
> Looking at kernel commit history I see PowerPC switched from 512 to
> 2048, and I don't see complaints about the ABI on the mailing list.
> 
> If COMMAND_LINE_SIZE is used by user space applications and we
> increase it there shouldn't be problems. I would expect things to
> work, but just get truncated boot args? That is the application will
> continue only to look at the initial 512 chars.

 The macro is in an include/uapi header, so it's exported to the userland 
and a part of the user API.  I don't know what the consequences are for 
the RISC-V port specifically, but it has raised my attention, and I think 
it has to be investigated.

 Perhaps it's OK to change it after all, but you'd have to go through 
known/potential users of this macro.  I guess there shouldn't be that many 
of them.

 In any case it cannot depend on Kconfig, because the userland won't have 
access to the configuration, and then presumably wants to handle any and 
all.

  Maciej


Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-04-02 Thread Alexei Starovoitov
On Fri, Apr 2, 2021 at 8:27 AM Kumar Kartikeya Dwivedi  wrote:
>
> This would be fine, because it's not a fast path or anything, but right now we
> return the id using the netlink response, otherwise for query we have to open
> the socket, prepare the msg, send and recv again. So it's a minor 
> optimization.
>
> However, there's one other problem. In an earlier version of this series, I
> didn't keep the id/index out parameters (to act as handle to the newly 
> attached
> filter/action). This lead to problems on query. Suppose a user doesn't 
> properly
> fill the opts during query (e.g. in case of filters). This means the netlink
> dump includes all filters matching filled in attributes. If the prog_id for 
> all
> of these is same (e.g. all have same bpf classifier prog attached to them), it
> becomes impossible to determine which one is the filter user asked for. It is
> not possible to enforce filling in all kinds of attributes since some can be
> left out and assigned by default in the kernel (priority, chain_index etc.). 
> So
> returning the newly created filter's id turned out to be the best option. This
> is also used to stash filter related information in bpf_link to properly 
> release
> it later.
>
> The same problem happens with actions, where we look up using the prog_id, we
> multiple actions with different index can match on same prog_id. It is not
> possible to determine which index corresponds to last loaded action.
>
> So unless there's a better idea on how to deal with this, a query API won't 
> work
> for the case where same bpf prog is attached more than once. Returning the
> id/index during attach seemed better than all other options we considered.

All of these things are messy because of tc legacy. bpf tried to follow tc style
with cls and act distinction and it didn't quite work. cls with
direct-action is the only
thing that became mainstream while tc style attach wasn't really addressed.
There were several incidents where tc had tens of thousands of progs attached
because of this attach/query/index weirdness described above.
I think the only way to address this properly is to introduce bpf_link style of
attaching to tc. Such bpf_link would support ingress/egress only.
direction-action will be implied. There won't be any index and query
will be obvious.
So I would like to propose to take this patch set a step further from
what Daniel said:
int bpf_tc_attach(prog_fd, ifindex, {INGRESS,EGRESS}):
and make this proposed api to return FD.
To detach from tc ingress/egress just close(fd).
The user processes will not conflict with each other and will not accidently
detach bpf program that was attached by another user process.
Such api will address the existing tc query/attach/detach race race conditions.
And libbpf side of support for this api will be trivial. Single bpf
link_create command
with ifindex and ingress|egress arguments.
wdyt?


Re: [PATCH RESEND 0/3] x86/sgx: eextend ioctl

2021-04-02 Thread Jethro Beekman
On 2021-04-02 17:53, Dave Hansen wrote:
> On 4/2/21 1:38 AM, Jethro Beekman wrote:
>>> So, we're talking here about pages that have been EEADDED, but for
>>> which we do not want to include the entire contents of the page?
>>> Do these contents always include the beginning of the page, or can
>>> the holes be anywhere?
>> Holes can be anywhere, and EEXTEND calls need not be sequential in
>> memory address or even relate to the most recently EADDed page.
> 
> I think you're referring to the SGX architecture itself here.  The
> architecture permits this, right?

Yes.

> But, why would an enclave loader application ever do this? 

e.g. to save space

> Is this something we want to support in Linux?

Why not? Is there a good reason to not fully support this part of the CPU 
architecture?

--
Jethro Beekman | Fortanix



smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PATCH] qemu_fw_cfg: Make fw_cfg_rev_attr a proper kobj_attribute

2021-04-02 Thread Nathan Chancellor
On Fri, Apr 02, 2021 at 11:25:42AM -0700, Kees Cook wrote:
> On Fri, Apr 02, 2021 at 08:42:07AM +0200, Sedat Dilek wrote:
> > On Thu, Feb 25, 2021 at 10:25 PM Kees Cook  wrote:
> > >
> > > On Thu, 11 Feb 2021 12:42:58 -0700, Nathan Chancellor wrote:
> > > > fw_cfg_showrev() is called by an indirect call in kobj_attr_show(),
> > > > which violates clang's CFI checking because fw_cfg_showrev()'s second
> > > > parameter is 'struct attribute', whereas the ->show() member of 'struct
> > > > kobj_structure' expects the second parameter to be of type 'struct
> > > > kobj_attribute'.
> > > >
> > > > $ cat /sys/firmware/qemu_fw_cfg/rev
> > > > 3
> > > >
> > > > [...]
> > >
> > > Applied to kspp/cfi/cleanups, thanks!
> > >
> > > [1/1] qemu_fw_cfg: Make fw_cfg_rev_attr a proper kobj_attribute
> > >   https://git.kernel.org/kees/c/f5c4679d6c49
> > >
> > 
> > I have queued this up in my custom patchset
> > (for-5.12/kspp-cfi-cleanups-20210225).
> > 
> > What is the plan to get this upstream?
> 
> I haven't sent it to Linus yet -- I was expecting to batch more of these
> and send them for v5.13. (But if the kvm folks snag it, that's good
> too.)

I am going to be putting the CFI series through its paces on both arm64
and x86_64 over the next week or so on several different machines (in
fact, I am writing up a report right now) so I will probably have some
more of these as I find them.

Cheers,
Nathan


Re: [PATCH 1/2] zram: fix crashes due to use of cpu hotplug multistate

2021-04-02 Thread Luis Chamberlain
On Fri, Apr 02, 2021 at 09:54:12AM +0200, Greg KH wrote:
> On Thu, Apr 01, 2021 at 11:59:25PM +, Luis Chamberlain wrote:
> > As for the syfs deadlock possible with drivers, this fixes it in a generic 
> > way:
> > 
> > commit fac43d8025727a74f80a183cc5eb74ed902a5d14
> > Author: Luis Chamberlain 
> > Date:   Sat Mar 27 14:58:15 2021 +
> > 
> > sysfs: add optional module_owner to attribute
> > 
> > This is needed as otherwise the owner of the attribute
> > or group read/store might have a shared lock used on driver removal,
> > and deadlock if we race with driver removal.
> > 
> > Signed-off-by: Luis Chamberlain 
> 
> No, please no.  Module removal is a "best effort",

Not for live patching. I am not sure if I am missing any other valid
use case?

> if the system dies when it happens, that's on you. 

I think the better approach for now is simply to call testers / etc to
deal with this open coded. I cannot be sure that other than live
patching there may be other valid use cases for module removal, and for
races we really may care for where userspace *will* typically be mucking
with sysfs attributes. Monitoring my systems's sysfs attributes I am
actually quite surprised at the random pokes at them.

> I am not willing to expend extra energy
> and maintance of core things like sysfs for stuff like this that does
> not matter in any system other than a developer's box.

Should we document this as well? Without this it is unclear that tons of
random tests are sanely nullified. At least this dead lock I spotted can
be pretty common form on many drivers.

> Lock data, not code please.  Trying to tie data structure's lifespans
> to the lifespan of code is a tangled mess, and one that I do not want to
> add to in any form.

Driver developers will simply have to open code these protections. In
light of what I see on LTP / fuzzing, I suspect the use case will grow
and we'll have to revisit this in the future. But for now, sure, we can
just open code the required protections everywhere to not crash on module
removal.

  Luis


Compiling Linux kernel into a build directory

2021-04-02 Thread James Courtier-Dutton
Hi,

Currently, when one builds the linux kernel, it places .o files all
over the source code tree.
Is there a way to have the linux kernel build, but place all the .o
files into a separate build folder?
Similar to how cmake or ninja work when building C source code.

One possible advantage of this approach is one can then put the build
folder on a ram disk / tmpfs   and be able to compile and test much
quicker.

Kind Regards

James


Re: [PATCH 1/4] mm/page_reporting: Introduce free page reported counters

2021-04-02 Thread Alexander Duyck
On Fri, Mar 26, 2021 at 2:45 AM Xunlei Pang  wrote:
>
> It's useful to know how many memory has been actually reported,
> so add new zone::reported_pages to record that.
>
> Add "/sys/kernel/mm/page_reporting/reported_kbytes" for the
> actual memory has been reported.
>
> Add "/sys/kernel/mm/page_reporting/refault_kbytes" for the
> accumulated memory has refaulted in after been reported out.
>
> Signed-off-by: Xunlei Pang 
> ---
>  include/linux/mmzone.h |   3 ++
>  mm/page_alloc.c|   4 +-
>  mm/page_reporting.c| 112 
> +++--
>  mm/page_reporting.h|   5 +++
>  4 files changed, 119 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index 47946ce..ebd169f 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -530,6 +530,9 @@ struct zone {
> atomic_long_t   managed_pages;
> unsigned long   spanned_pages;
> unsigned long   present_pages;
> +#ifdef CONFIG_PAGE_REPORTING
> +   unsigned long   reported_pages;
> +#endif
>  #ifdef CONFIG_CMA
> unsigned long   cma_pages;
>  #endif
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 3e4b29ee..c2c5688 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -930,8 +930,10 @@ static inline void del_page_from_free_list(struct page 
> *page, struct zone *zone,
>unsigned int order)
>  {
> /* clear reported state and update reported page count */
> -   if (page_reported(page))
> +   if (page_reported(page)) {
> __ClearPageReported(page);
> +   page_reporting_update_refault(zone, 1 << order);
> +   }
>
> list_del(>lru);
> __ClearPageBuddy(page);
> diff --git a/mm/page_reporting.c b/mm/page_reporting.c
> index c50d93f..ba195ea 100644
> --- a/mm/page_reporting.c
> +++ b/mm/page_reporting.c
> @@ -1,4 +1,5 @@
>  // SPDX-License-Identifier: GPL-2.0
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -19,6 +20,22 @@ enum {
> PAGE_REPORTING_ACTIVE
>  };
>
> +#ifdef CONFIG_SYSFS
> +static struct percpu_counter refault_pages;
> +
> +void page_reporting_update_refault(struct zone *zone, unsigned int pages)
> +{
> +   zone->reported_pages -= pages;
> +   percpu_counter_add_batch(_pages, pages, INT_MAX / 2);
> +}
> +#else
> +void page_reporting_update_refault(struct zone *zone, unsigned int pages)
> +{
> +   zone->reported_pages -= pages;
> +}
> +#endif
> +
> +

I don't see the value added from the refault_pages counter.
Essentially all it will tell you is how many reported pages were
allocated. If you are really wanting to track a value such as this it
might make more sense to just track the total number of reported pages
over the lifetime of the system. At least with that you would once
again be able to take advantage of batching so it isn't occurring as
often.

>  /* request page reporting */
>  static void
>  __page_reporting_request(struct page_reporting_dev_info *prdev)
> @@ -66,7 +83,8 @@ void __page_reporting_notify(void)
>
>  static void
>  page_reporting_drain(struct page_reporting_dev_info *prdev,
> -struct scatterlist *sgl, unsigned int nents, bool 
> reported)
> +struct scatterlist *sgl, struct zone *zone,
> +unsigned int nents, bool reported)
>  {
> struct scatterlist *sg = sgl;
>
> @@ -92,8 +110,10 @@ void __page_reporting_notify(void)
>  * report on the new larger page when we make our way
>  * up to that higher order.
>  */
> -   if (PageBuddy(page) && buddy_order(page) == order)
> +   if (PageBuddy(page) && buddy_order(page) == order) {
> __SetPageReported(page);
> +   zone->reported_pages += (1 << order);
> +   }

The parenthesis around "1 << order" is redundant.

> } while ((sg = sg_next(sg)));
>
> /* reinitialize scatterlist now that it is empty */
> @@ -197,7 +217,7 @@ void __page_reporting_notify(void)
> spin_lock_irq(>lock);
>
> /* flush reported pages from the sg list */
> -   page_reporting_drain(prdev, sgl, PAGE_REPORTING_CAPACITY, 
> !err);
> +   page_reporting_drain(prdev, sgl, zone, 
> PAGE_REPORTING_CAPACITY, !err);
>
> /*
>  * Reset next to first entry, the old next isn't valid
> @@ -260,7 +280,7 @@ void __page_reporting_notify(void)
>
> /* flush any remaining pages out from the last report */
> spin_lock_irq(>lock);
> -   page_reporting_drain(prdev, sgl, leftover, !err);
> +   page_reporting_drain(prdev, sgl, zone, leftover, !err);
> spin_unlock_irq(>lock);
> }
>
> @@ -362,3 +382,87 @@ void page_reporting_unregister(struct 
> 

[PATCH v4 2/4] drivers/tty/serial/8250: refactor sirq and lpc address setting code

2021-04-02 Thread Zev Weiss
This splits dedicated aspeed_vuart_set_{sirq,lpc_address}() functions
out of the sysfs store functions in preparation for adding DT
properties that will be poking the same registers.  While we're at it,
these functions now provide some basic bounds-checking on their
arguments.

Signed-off-by: Zev Weiss 
---
 drivers/tty/serial/8250/8250_aspeed_vuart.c | 51 ++---
 1 file changed, 35 insertions(+), 16 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c 
b/drivers/tty/serial/8250/8250_aspeed_vuart.c
index c33e02cbde93..8433f8dbb186 100644
--- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
+++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
@@ -72,22 +72,31 @@ static ssize_t lpc_address_show(struct device *dev,
return snprintf(buf, PAGE_SIZE - 1, "0x%x\n", addr);
 }
 
+static int aspeed_vuart_set_lpc_address(struct aspeed_vuart *vuart, u32 addr)
+{
+   if (addr > U16_MAX)
+   return -EINVAL;
+
+   writeb(addr >> 8, vuart->regs + ASPEED_VUART_ADDRH);
+   writeb(addr >> 0, vuart->regs + ASPEED_VUART_ADDRL);
+
+   return 0;
+}
+
 static ssize_t lpc_address_store(struct device *dev,
 struct device_attribute *attr,
 const char *buf, size_t count)
 {
struct aspeed_vuart *vuart = dev_get_drvdata(dev);
-   unsigned long val;
+   u32 val;
int err;
 
-   err = kstrtoul(buf, 0, );
+   err = kstrtou32(buf, 0, );
if (err)
return err;
 
-   writeb(val >> 8, vuart->regs + ASPEED_VUART_ADDRH);
-   writeb(val >> 0, vuart->regs + ASPEED_VUART_ADDRL);
-
-   return count;
+   err = aspeed_vuart_set_lpc_address(vuart, val);
+   return err ? : count;
 }
 
 static DEVICE_ATTR_RW(lpc_address);
@@ -105,27 +114,37 @@ static ssize_t sirq_show(struct device *dev,
return snprintf(buf, PAGE_SIZE - 1, "%u\n", reg);
 }
 
+static int aspeed_vuart_set_sirq(struct aspeed_vuart *vuart, u32 sirq)
+{
+   u8 reg;
+
+   if (sirq > (ASPEED_VUART_GCRB_HOST_SIRQ_MASK >> 
ASPEED_VUART_GCRB_HOST_SIRQ_SHIFT))
+   return -EINVAL;
+
+   sirq <<= ASPEED_VUART_GCRB_HOST_SIRQ_SHIFT;
+   sirq &= ASPEED_VUART_GCRB_HOST_SIRQ_MASK;
+
+   reg = readb(vuart->regs + ASPEED_VUART_GCRB);
+   reg &= ~ASPEED_VUART_GCRB_HOST_SIRQ_MASK;
+   reg |= sirq;
+   writeb(reg, vuart->regs + ASPEED_VUART_GCRB);
+
+   return 0;
+}
+
 static ssize_t sirq_store(struct device *dev, struct device_attribute *attr,
  const char *buf, size_t count)
 {
struct aspeed_vuart *vuart = dev_get_drvdata(dev);
unsigned long val;
int err;
-   u8 reg;
 
err = kstrtoul(buf, 0, );
if (err)
return err;
 
-   val <<= ASPEED_VUART_GCRB_HOST_SIRQ_SHIFT;
-   val &= ASPEED_VUART_GCRB_HOST_SIRQ_MASK;
-
-   reg = readb(vuart->regs + ASPEED_VUART_GCRB);
-   reg &= ~ASPEED_VUART_GCRB_HOST_SIRQ_MASK;
-   reg |= val;
-   writeb(reg, vuart->regs + ASPEED_VUART_GCRB);
-
-   return count;
+   err = aspeed_vuart_set_sirq(vuart, val);
+   return err ? : count;
 }
 
 static DEVICE_ATTR_RW(sirq);
-- 
2.31.1



[PATCH v4 1/4] dt-bindings: serial: 8250: deprecate aspeed,sirq-polarity-sense

2021-04-02 Thread Zev Weiss
This property ties SIRQ polarity to SCU register bits that don't
necessarily have any direct relationship to it; the only use of it
was removed in commit c82bf6e133d30e0f9172a20807814fa28aef0f67.

Signed-off-by: Zev Weiss 
Reviewed-by: Joel Stanley 
---
 Documentation/devicetree/bindings/serial/8250.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/serial/8250.yaml 
b/Documentation/devicetree/bindings/serial/8250.yaml
index f54cae9ff7b2..491b9297432d 100644
--- a/Documentation/devicetree/bindings/serial/8250.yaml
+++ b/Documentation/devicetree/bindings/serial/8250.yaml
@@ -188,6 +188,7 @@ properties:
   offset and bit number to identify how the SIRQ polarity should be
   configured. One possible data source is the LPC/eSPI mode bit. Only
   applicable to aspeed,ast2500-vuart.
+deprecated: true
 
 required:
   - reg
-- 
2.31.1



[PATCH v4 4/4] dt-bindings: serial: 8250: add aspeed,lpc-io-reg and aspeed,lpc-interrupts

2021-04-02 Thread Zev Weiss
These correspond to the existing lpc_address, sirq, and sirq_polarity
sysfs attributes; the second element of aspeed,lpc-interrupts provides
a replacement for the deprecated aspeed,sirq-polarity-sense property.

Signed-off-by: Zev Weiss 
---
 .../devicetree/bindings/serial/8250.yaml  | 27 ---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/serial/8250.yaml 
b/Documentation/devicetree/bindings/serial/8250.yaml
index 491b9297432d..0e82b076e199 100644
--- a/Documentation/devicetree/bindings/serial/8250.yaml
+++ b/Documentation/devicetree/bindings/serial/8250.yaml
@@ -12,8 +12,13 @@ maintainers:
 allOf:
   - $ref: /schemas/serial.yaml#
   - if:
-  required:
-- aspeed,sirq-polarity-sense
+  anyOf:
+- required:
+- aspeed,lpc-io-reg
+- required:
+- aspeed,lpc-interrupts
+- required:
+- aspeed,sirq-polarity-sense
 then:
   properties:
 compatible:
@@ -190,6 +195,20 @@ properties:
   applicable to aspeed,ast2500-vuart.
 deprecated: true
 
+  aspeed,lpc-io-reg:
+$ref: '/schemas/types.yaml#/definitions/uint32'
+description: |
+  The VUART LPC address.  Only applicable to aspeed,ast2500-vuart.
+
+  aspeed,lpc-interrupts:
+$ref: "/schemas/types.yaml#/definitions/uint32-array"
+minItems: 2
+maxItems: 2
+description: |
+  A 2-cell property describing the VUART SIRQ number and SIRQ
+  polarity (IRQ_TYPE_LEVEL_LOW or IRQ_TYPE_LEVEL_HIGH).  Only
+  applicable to aspeed,ast2500-vuart.
+
 required:
   - reg
   - interrupts
@@ -221,6 +240,7 @@ examples:
 };
   - |
 #include 
+#include 
 serial@1e787000 {
 compatible = "aspeed,ast2500-vuart";
 reg = <0x1e787000 0x40>;
@@ -228,7 +248,8 @@ examples:
 interrupts = <8>;
 clocks = < ASPEED_CLK_APB>;
 no-loopback-test;
-aspeed,sirq-polarity-sense = < 0x70 25>;
+aspeed,lpc-io-reg = <0x3f8>;
+aspeed,lpc-interrupts = <4 IRQ_TYPE_LEVEL_LOW>;
 };
 
 ...
-- 
2.31.1



[PATCH v4 3/4] drivers/tty/serial/8250: add aspeed,lpc-io-reg and aspeed,lpc-interrupts DT properties

2021-04-02 Thread Zev Weiss
These allow describing all the Aspeed VUART attributes currently
available via sysfs.  aspeed,sirq provides a replacement for the
deprecated aspeed,sirq-polarity-sense property.

Signed-off-by: Zev Weiss 
---
 drivers/tty/serial/8250/8250_aspeed_vuart.c | 44 -
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c 
b/drivers/tty/serial/8250/8250_aspeed_vuart.c
index 8433f8dbb186..75ef006fa24b 100644
--- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
+++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
@@ -28,6 +28,10 @@
 #define ASPEED_VUART_ADDRL 0x28
 #define ASPEED_VUART_ADDRH 0x2c
 
+#define ASPEED_VUART_DEFAULT_LPC_ADDR  0x3f8
+#define ASPEED_VUART_DEFAULT_SIRQ  4
+#define ASPEED_VUART_DEFAULT_SIRQ_POLARITY IRQ_TYPE_LEVEL_LOW
+
 struct aspeed_vuart {
struct device   *dev;
void __iomem*regs;
@@ -393,7 +397,8 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
struct aspeed_vuart *vuart;
struct device_node *np;
struct resource *res;
-   u32 clk, prop;
+   u32 clk, prop, sirq[2];
+   bool sirq_polarity;
int rc;
 
np = pdev->dev.of_node;
@@ -501,6 +506,43 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
of_node_put(sirq_polarity_sense_args.np);
}
 
+   rc = of_property_read_u32(np, "aspeed,lpc-io-reg", );
+   if (rc < 0)
+   prop = ASPEED_VUART_DEFAULT_LPC_ADDR;
+
+   rc = aspeed_vuart_set_lpc_address(vuart, prop);
+   if (rc < 0) {
+   dev_err(>dev, "invalid value in aspeed,lpc-io-reg 
property\n");
+   goto err_clk_disable;
+   }
+
+   rc = of_property_read_u32_array(np, "aspeed,lpc-interrupts", sirq, 2);
+   if (rc < 0) {
+   sirq[0] = ASPEED_VUART_DEFAULT_SIRQ;
+   sirq[1] = ASPEED_VUART_DEFAULT_SIRQ_POLARITY;
+   }
+
+   rc = aspeed_vuart_set_sirq(vuart, sirq[0]);
+   if (rc < 0) {
+   dev_err(>dev, "invalid sirq number in 
aspeed,lpc-interrupts property\n");
+   goto err_clk_disable;
+   }
+
+   switch (sirq[1]) {
+   case IRQ_TYPE_LEVEL_LOW:
+   sirq_polarity = false;
+   break;
+   case IRQ_TYPE_LEVEL_HIGH:
+   sirq_polarity = true;
+   break;
+   default:
+   dev_err(>dev, "invalid sirq polarity in 
aspeed,lpc-interrupts property\n");
+   rc = -EINVAL;
+   goto err_clk_disable;
+   }
+
+   aspeed_vuart_set_sirq_polarity(vuart, sirq_polarity);
+
aspeed_vuart_set_enabled(vuart, true);
aspeed_vuart_set_host_tx_discard(vuart, true);
platform_set_drvdata(pdev, vuart);
-- 
2.31.1



[PATCH v4 0/4] aspeed-vuart: generalized DT properties

2021-04-02 Thread Zev Weiss
This series generalizes the aspeed-vuart driver's device tree
properties to cover all the attributes it currently exposes via sysfs.

The aspeed,sirq-polarity-sense property was a bit of a design mistake
in that it ties Aspeed VUART SIRQ polarity to SCU register bits that
aren't really inherently related to it; the first patch in this series
deprecates it (though we hope to eventually remove it).

The rest of the series adds two new properties, aspeed,lpc-io-reg and
aspeed,lpc-interrupts.  The latter allows describing the SIRQ polarity
(along with the interrupt number) directly, providing a simpler
replacement for aspeed,sirq-polarity-sense.


Changes since v3 [2]:
 - renamed properties to match aspeed,ast2400-kcs-bmc

Changes since v2 [0]:
 - expanded to also handle sirq number and lpc address in addition to
   sirq polarity
 - added default settings if DT properties not specified
 - refactored existing sysfs code slightly, adding range checks
 - cleaned up 'make dt_binding_check' warnings

Changes since v1 [1]:
 - deprecate and retain aspeed,sirq-polarity-sense instead of removing it
 - drop e3c246d4i dts addition from this series


[0] 
https://lore.kernel.org/openbmc/20210401005702.28271-1-...@bewilderbeest.net/
[1] https://lore.kernel.org/openbmc/20210330002338.335-1-...@bewilderbeest.net/
[2] 
https://lore.kernel.org/openbmc/20210402004716.15961-1-...@bewilderbeest.net/


Zev Weiss (4):
  dt-bindings: serial: 8250: deprecate aspeed,sirq-polarity-sense
  drivers/tty/serial/8250: refactor sirq and lpc address setting code
  drivers/tty/serial/8250: add aspeed,lpc-io-reg and
aspeed,lpc-interrupts DT properties
  dt-bindings: serial: 8250: add aspeed,lpc-io-reg and
aspeed,lpc-interrupts

 .../devicetree/bindings/serial/8250.yaml  | 28 +-
 drivers/tty/serial/8250/8250_aspeed_vuart.c   | 95 +++
 2 files changed, 103 insertions(+), 20 deletions(-)

-- 
2.31.1



[PATCH] wireless: marvell: mwl8k: Fix a double Free in mwl8k_probe_hw

2021-04-02 Thread Lv Yunlong
In mwl8k_probe_hw, hw->priv->txq is freed at the first time by
dma_free_coherent() in the call chain:
if(!priv->ap_fw)->mwl8k_init_txqs(hw)->mwl8k_txq_init(hw, i).

Then in err_free_queues of mwl8k_probe_hw, hw->priv->txq is freed
at the second time by mwl8k_txq_deinit(hw, i)->dma_free_coherent().

My patch set txq->txd to NULL after the first free to avoid the
double free.

Fixes: a66098daacee2 ("mwl8k: Marvell TOPDOG wireless driver")
Signed-off-by: Lv Yunlong 
---
 drivers/net/wireless/marvell/mwl8k.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/marvell/mwl8k.c 
b/drivers/net/wireless/marvell/mwl8k.c
index c9f8c056aa51..84b32a5f01ee 100644
--- a/drivers/net/wireless/marvell/mwl8k.c
+++ b/drivers/net/wireless/marvell/mwl8k.c
@@ -1473,6 +1473,7 @@ static int mwl8k_txq_init(struct ieee80211_hw *hw, int 
index)
if (txq->skb == NULL) {
dma_free_coherent(>pdev->dev, size, txq->txd,
  txq->txd_dma);
+   txq->txd = NULL;
return -ENOMEM;
}
 
-- 
2.25.1




Re: [PATCH] qemu_fw_cfg: Make fw_cfg_rev_attr a proper kobj_attribute

2021-04-02 Thread Kees Cook
On Fri, Apr 02, 2021 at 08:42:07AM +0200, Sedat Dilek wrote:
> On Thu, Feb 25, 2021 at 10:25 PM Kees Cook  wrote:
> >
> > On Thu, 11 Feb 2021 12:42:58 -0700, Nathan Chancellor wrote:
> > > fw_cfg_showrev() is called by an indirect call in kobj_attr_show(),
> > > which violates clang's CFI checking because fw_cfg_showrev()'s second
> > > parameter is 'struct attribute', whereas the ->show() member of 'struct
> > > kobj_structure' expects the second parameter to be of type 'struct
> > > kobj_attribute'.
> > >
> > > $ cat /sys/firmware/qemu_fw_cfg/rev
> > > 3
> > >
> > > [...]
> >
> > Applied to kspp/cfi/cleanups, thanks!
> >
> > [1/1] qemu_fw_cfg: Make fw_cfg_rev_attr a proper kobj_attribute
> >   https://git.kernel.org/kees/c/f5c4679d6c49
> >
> 
> I have queued this up in my custom patchset
> (for-5.12/kspp-cfi-cleanups-20210225).
> 
> What is the plan to get this upstream?

I haven't sent it to Linus yet -- I was expecting to batch more of these
and send them for v5.13. (But if the kvm folks snag it, that's good
too.)

-Kees

> 
> Feel free to add my:
> 
> Tested-by: Sedat Dilek 
> 
> - Sedat -

-- 
Kees Cook


Re: [PATCH v2 00/10] ipmi_si: Set of clean ups

2021-04-02 Thread Corey Minyard
On Fri, Apr 02, 2021 at 08:43:24PM +0300, Andy Shevchenko wrote:
> The series contains set of clean ups, main parts of which are:
>  - use ne platform_get_mem_or_io() API
>  - use match_string() API

As I have already said, a very nice set of cleanups.  Thank you.
These are applied and in the ipmi linux-next tree.

-corey

> 
> Since v2:
> - patch 3: rephrased commit message (Corey)
> - patch 5: added a comment that array maps to enum (Corey)
> - patch 5: added "ipmi" prefix to the name of the array
> - patch 6: just exported array w/o moving to header (Corey)
> - wrapped up cover letter
> 
> Andy Shevchenko (10):
>   ipmi_si: Switch to use platform_get_mem_or_io()
>   ipmi_si: Remove bogus err_free label
>   ipmi_si: Utilize temporary variable to hold device pointer
>   ipmi_si: Use proper ACPI macros to check error code for failures
>   ipmi_si: Introduce ipmi_panic_event_str[] array
>   ipmi_si: Reuse si_to_str[] array in ipmi_hardcode_init_one()
>   ipmi_si: Get rid of ->addr_source_cleanup()
>   ipmi_si: Use strstrip() to remove surrounding spaces
>   ipmi_si: Drop redundant check before calling put_device()
>   ipmi_si: Join string literals back
> 
>  drivers/char/ipmi/ipmi_msghandler.c  | 54 ++--
>  drivers/char/ipmi/ipmi_si.h  |  8 ++-
>  drivers/char/ipmi/ipmi_si_hardcode.c | 73 -
>  drivers/char/ipmi/ipmi_si_hotmod.c   | 24 ++-
>  drivers/char/ipmi/ipmi_si_intf.c | 32 --
>  drivers/char/ipmi/ipmi_si_pci.c  | 22 ++-
>  drivers/char/ipmi/ipmi_si_platform.c | 95 
>  7 files changed, 112 insertions(+), 196 deletions(-)
> 
> -- 
> 2.30.2
> 


Re: [PATCH] lib/string: Introduce sysfs_streqcase

2021-04-02 Thread Kees Cook
On Fri, Apr 02, 2021 at 11:17:13AM -0700, Nick Desaulniers wrote:
> Thanks for the patch!
> 
> + akpm (please remember to run ./scripts/get_maintainer.pl on your patch 
> files)
> 
> On Fri, Apr 2, 2021 at 2:41 AM Gioh Kim  wrote:
> >
> > As the name shows, it checks if strings are equal in case insensitive
> > manner. I found some cases using strncasecmp to check the entire
> > strings and they would not work as intended.
> >
> > For example, drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c uses
> > strncasecmp to check that the input via sysfs is "mi". But it would
> > work even-if the input is "min-wrongcommand".
> > And also drivers/pnp/interface.c checks "disable" command with
> > strncasecmp but it would also work if the command is "disable-wrong".
> 
> Perhaps those callers should be using strcasecmp then, rather than 
> strncasecmp?
> 
> Also, if they're being liberal in accepting either case, I don't see
> why the sysfs nodes should be strict in rejecting trailing input at
> that point.

I think this shouldn't be prefixed "sysfs_" -- name it for what it does,
not where it gets used, if it's a general utility function.

-Kees

> 
> >
> > Signed-off-by: Gioh Kim 
> > ---
> >  lib/string.c | 23 +++
> >  1 file changed, 23 insertions(+)
> >
> > diff --git a/lib/string.c b/lib/string.c
> > index 7548eb715ddb..5e6bc0d3d5c6 100644
> > --- a/lib/string.c
> > +++ b/lib/string.c
> > @@ -714,6 +714,29 @@ bool sysfs_streq(const char *s1, const char *s2)
> >  }
> >  EXPORT_SYMBOL(sysfs_streq);
> >
> > +/**
> > + * sysfs_streqcase - same to sysfs_streq and case insensitive
> > + * @s1: one string
> > + * @s2: another string
> > + *
> > + */
> > +bool sysfs_streqcase(const char *s1, const char *s2)
> > +{
> > +   while (*s1 && tolower(*s1) == tolower(*s2)) {
> > +   s1++;
> > +   s2++;
> > +   }
> > +
> > +   if (*s1 == *s2)
> > +   return true;
> > +   if (!*s1 && *s2 == '\n' && !s2[1])
> > +   return true;
> > +   if (*s1 == '\n' && !s1[1] && !*s2)
> > +   return true;
> > +   return false;
> > +}
> > +EXPORT_SYMBOL(sysfs_streqcase);
> 
> This should be declared in
> include/linux/string.h
> in order for others to use this (as 0day bot notes).
> 
> > +
> >  /**
> >   * match_string - matches given string in an array
> >   * @array: array of strings
> > --
> > 2.25.1
> >
> 
> 
> --
> Thanks,
> ~Nick Desaulniers

-- 
Kees Cook


Re: [PATCH 1/1] dmaengine: idxd: Add IDXD performance monitor support

2021-04-02 Thread kernel test robot
Hi Tom,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on vkoul-dmaengine/next]
[also build test WARNING on linux/master linus/master v5.12-rc5 next-20210401]
[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/Tom-Zanussi/dmaengine-idxd-IDXD-pmu-support/20210403-005240
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine.git next
config: x86_64-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# 
https://github.com/0day-ci/linux/commit/ef9587b8e4ebe37a46d89b14ed68fb321e33242f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Tom-Zanussi/dmaengine-idxd-IDXD-pmu-support/20210403-005240
git checkout ef9587b8e4ebe37a46d89b14ed68fb321e33242f
# save the attached .config to linux build tree
make W=1 ARCH=x86_64 

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

All warnings (new ones prefixed by >>):

   drivers/dma/idxd/perfmon.c: In function 'perfmon_pmu_event_init':
>> drivers/dma/idxd/perfmon.c:192:17: warning: variable 'dev' set but not used 
>> [-Wunused-but-set-variable]
 192 |  struct device *dev;
 | ^~~
   drivers/dma/idxd/perfmon.c: In function 'perfmon_pmu_read_counter':
   drivers/dma/idxd/perfmon.c:228:17: warning: variable 'dev' set but not used 
[-Wunused-but-set-variable]
 228 |  struct device *dev;
 | ^~~
   drivers/dma/idxd/perfmon.c: In function 'perfmon_pmu_event_start':
   drivers/dma/idxd/perfmon.c:325:17: warning: variable 'dev' set but not used 
[-Wunused-but-set-variable]
 325 |  struct device *dev;
 | ^~~
>> drivers/dma/idxd/perfmon.c:323:19: warning: variable 'idxd_pmu' set but not 
>> used [-Wunused-but-set-variable]
 323 |  struct idxd_pmu *idxd_pmu;
 |   ^~~~


vim +/dev +192 drivers/dma/idxd/perfmon.c

   188  
   189  static int perfmon_pmu_event_init(struct perf_event *event)
   190  {
   191  struct idxd_device *idxd;
 > 192  struct device *dev;
   193  int ret = 0;
   194  
   195  idxd = event_to_idxd(event);
   196  dev = >pdev->dev;
   197  event->hw.idx = -1;
   198  
   199  if (event->attr.type != event->pmu->type)
   200  return -ENOENT;
   201  
   202  /* sampling not supported */
   203  if (event->attr.sample_period)
   204  return -EINVAL;
   205  
   206  if (event->cpu < 0)
   207  return -EINVAL;
   208  
   209  if (event->pmu != >idxd_pmu->pmu)
   210  return -EINVAL;
   211  
   212  event->hw.event_base = ioread64(PERFMON_TABLE_OFFSET(idxd));
   213  event->cpu = idxd->idxd_pmu->cpu;
   214  event->hw.config = event->attr.config;
   215  
   216  if (event->group_leader != event)
   217   /* non-group events have themselves as leader */
   218  ret = perfmon_validate_group(idxd->idxd_pmu, event);
   219  
   220  return ret;
   221  }
   222  
   223  static inline u64 perfmon_pmu_read_counter(struct perf_event *event)
   224  {
   225  struct hw_perf_event *hwc = >hw;
   226  struct idxd_device *idxd;
   227  int cntr = hwc->idx;
   228  struct device *dev;
   229  u64 cntrdata;
   230  
   231  idxd = event_to_idxd(event);
   232  dev = >pdev->dev;
   233  
   234  cntrdata = ioread64(CNTRDATA_REG(idxd, cntr));
   235  
   236  return cntrdata;
   237  }
   238  
   239  static void perfmon_pmu_event_update(struct perf_event *event)
   240  {
   241  struct idxd_device *idxd = event_to_idxd(event);
   242  u64 prev_raw_count, new_raw_count, delta, p, n;
   243  int shift = 64 - idxd->idxd_pmu->counter_width;
   244  struct hw_perf_event *hwc = >hw;
   245  
   246  do {
   247  prev_raw_count = local64_read(>prev_count);
   248  new_raw_count = perfmon_pmu_read_counter(event);
   249  } while (local64_cmpxchg(>prev_count, prev_raw_count,
   250  new_raw_count) != prev_raw_count);
   251  
   252  n = (new_raw_count << shift);
   253  p = (prev_raw_count << shift);
   254  
   255  delta = ((n - p) >> shift);
   256  
   257  local64_add(delta, >count);
   258  }
   259  
   260  void perfmon_counter_overflow(struct idxd_device *idxd)
   261  {
   262  int i, n_counters, max_loop = OVERFLOW_SIZE;
   263  struct perf_event *event;
   264  unsigned long ovfstatus;
   265 

[PATCH net-next v2 5/5] mvneta: recycle buffers

2021-04-02 Thread Matteo Croce
From: Matteo Croce 

Use the new recycling API for page_pool.
In a drop rate test, the packet rate increased di 10%,
from 269 Kpps to 296 Kpps.

perf top on a stock system shows:

Overhead  Shared Object Symbol
  21.78%  [kernel]  [k] __pi___inval_dcache_area
  21.66%  [mvneta]  [k] mvneta_rx_swbm
   7.00%  [kernel]  [k] kmem_cache_alloc
   6.05%  [kernel]  [k] eth_type_trans
   4.44%  [kernel]  [k] kmem_cache_free.part.0
   3.80%  [kernel]  [k] __netif_receive_skb_core
   3.68%  [kernel]  [k] dev_gro_receive
   3.65%  [kernel]  [k] get_page_from_freelist
   3.43%  [kernel]  [k] page_pool_release_page
   3.35%  [kernel]  [k] free_unref_page

And this is the same output with recycling enabled:

Overhead  Shared Object Symbol
  24.10%  [kernel]  [k] __pi___inval_dcache_area
  23.02%  [mvneta]  [k] mvneta_rx_swbm
   7.19%  [kernel]  [k] kmem_cache_alloc
   6.50%  [kernel]  [k] eth_type_trans
   4.93%  [kernel]  [k] __netif_receive_skb_core
   4.77%  [kernel]  [k] kmem_cache_free.part.0
   3.93%  [kernel]  [k] dev_gro_receive
   3.03%  [kernel]  [k] build_skb
   2.91%  [kernel]  [k] page_pool_put_page
   2.85%  [kernel]  [k] __xdp_return

The test was done with mausezahn on the TX side with 64 byte raw
ethernet frames.

Signed-off-by: Matteo Croce 
---
 drivers/net/ethernet/marvell/mvneta.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c 
b/drivers/net/ethernet/marvell/mvneta.c
index f20dfd1d7a6b..f88c189b60a4 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2331,7 +2331,7 @@ mvneta_swbm_build_skb(struct mvneta_port *pp, struct 
mvneta_rx_queue *rxq,
if (!skb)
return ERR_PTR(-ENOMEM);
 
-   page_pool_release_page(rxq->page_pool, virt_to_page(xdp->data));
+   skb_mark_for_recycle(skb, virt_to_page(xdp->data), >rxq->mem);
 
skb_reserve(skb, xdp->data - xdp->data_hard_start);
skb_put(skb, xdp->data_end - xdp->data);
@@ -2343,7 +2343,10 @@ mvneta_swbm_build_skb(struct mvneta_port *pp, struct 
mvneta_rx_queue *rxq,
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
skb_frag_page(frag), skb_frag_off(frag),
skb_frag_size(frag), PAGE_SIZE);
-   page_pool_release_page(rxq->page_pool, skb_frag_page(frag));
+   /* We don't need to reset pp_recycle here. It's already set, so
+* just mark fragments for recycling.
+*/
+   page_pool_store_mem_info(skb_frag_page(frag), >rxq->mem);
}
 
return skb;
-- 
2.30.2



Re: [PATCH net v2] atl1c: move tx cleanup processing out of interrupt

2021-04-02 Thread Eric Dumazet



On 4/2/21 7:20 PM, Gatis Peisenieks wrote:
> Tx queue cleanup happens in interrupt handler on same core as rx queue 
> processing.
> Both can take considerable amount of processing in high packet-per-second 
> scenarios.
> 

...

> @@ -2504,6 +2537,7 @@ static int atl1c_init_netdev(struct net_device *netdev, 
> struct pci_dev *pdev)
>  NETIF_F_TSO6;
>  netdev->features =    netdev->hw_features    |
>  NETIF_F_HW_VLAN_CTAG_TX;
> +    netdev->threaded = true;

Shouldn't it use dev_set_threaded() ?

>  return 0;
>  }
> 
> @@ -2588,6 +2622,7 @@ static int atl1c_probe(struct pci_dev *pdev, const 
> struct pci_device_id *ent)
>  adapter->mii.phy_id_mask = 0x1f;
>  adapter->mii.reg_num_mask = MDIO_CTRL_REG_MASK;
>  netif_napi_add(netdev, >napi, atl1c_clean, 64);
> +    netif_napi_add(netdev, >tx_napi, atl1c_clean_tx, 64);
>  timer_setup(>phy_config_timer, atl1c_phy_config, 0);
>  /* setup the private structure */
>  err = atl1c_sw_init(adapter);


Re: [RESEND PATCH] bus: mhi: core: Remove pre_init flag used for power purposes

2021-04-02 Thread Hemant Kumar




On 4/1/21 2:41 PM, Bhaumik Bhatt wrote:

Some controllers can choose to skip preparation for power up.
In that case, device context is initialized based on the pre_init
flag not being set during mhi_prepare_for_power_up(). There is no
reason MHI host driver should maintain and provide controllers
with two separate paths for preparing MHI.

Going forward, all controllers will be required to call the
mhi_prepare_for_power_up() API followed by their choice of sync
or async power up. This allows MHI host driver to get rid of the
pre_init flag and sets up a common way for all controllers to use
MHI. This also helps controllers fail early on during preparation
phase in some failure cases.

Signed-off-by: Bhaumik Bhatt 
---
This patch was tested on arm64 architecture.


Change looks good as current MHI controllers ath11k and pci generic are 
not using pre_init.


Reviewed-by: Hemant Kumar 

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


[PATCH net-next v2 4/5] mvpp2: recycle buffers

2021-04-02 Thread Matteo Croce
From: Matteo Croce 

Use the new recycling API for page_pool.
In a drop rate test, the packet rate is more than doubled,
from 962 Kpps to 2047 Kpps.

perf top on a stock system shows:

Overhead  Shared Object Symbol
  30.67%  [kernel]  [k] page_pool_release_page
   8.37%  [kernel]  [k] get_page_from_freelist
   7.34%  [kernel]  [k] free_unref_page
   6.47%  [mvpp2]   [k] mvpp2_rx
   4.69%  [kernel]  [k] eth_type_trans
   4.55%  [kernel]  [k] __netif_receive_skb_core
   4.40%  [kernel]  [k] build_skb
   4.29%  [kernel]  [k] kmem_cache_free
   4.00%  [kernel]  [k] kmem_cache_alloc
   3.81%  [kernel]  [k] dev_gro_receive

With packet rate stable at 962 Kpps:

tx: 0 bps 0 pps rx: 477.4 Mbps 962.6 Kpps
tx: 0 bps 0 pps rx: 477.6 Mbps 962.8 Kpps
tx: 0 bps 0 pps rx: 477.6 Mbps 962.9 Kpps
tx: 0 bps 0 pps rx: 477.2 Mbps 962.1 Kpps
tx: 0 bps 0 pps rx: 477.5 Mbps 962.7 Kpps

And this is the same output with recycling enabled:

Overhead  Shared Object Symbol
  12.75%  [mvpp2]   [k] mvpp2_rx
   9.56%  [kernel]  [k] __netif_receive_skb_core
   9.29%  [kernel]  [k] build_skb
   9.27%  [kernel]  [k] eth_type_trans
   8.39%  [kernel]  [k] kmem_cache_alloc
   7.85%  [kernel]  [k] kmem_cache_free
   7.36%  [kernel]  [k] page_pool_put_page
   6.45%  [kernel]  [k] dev_gro_receive
   4.72%  [kernel]  [k] __xdp_return
   3.06%  [kernel]  [k] page_pool_refill_alloc_cache

With packet rate above 2000 Kpps:

tx: 0 bps 0 pps rx: 1015 Mbps 2046 Kpps
tx: 0 bps 0 pps rx: 1015 Mbps 2047 Kpps
tx: 0 bps 0 pps rx: 1015 Mbps 2047 Kpps
tx: 0 bps 0 pps rx: 1015 Mbps 2047 Kpps
tx: 0 bps 0 pps rx: 1015 Mbps 2047 Kpps

The major performance increase is explained by the fact that the most CPU
consuming functions (page_pool_release_page, get_page_from_freelist
and free_unref_page) are no longer called on a per packet basis.

The test was done by sending to the macchiatobin 64 byte ethernet frames
with an invalid ethertype, so the packets are dropped early in the RX path.

Signed-off-by: Matteo Croce 
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c 
b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index ec706d614cac..633b39cfef65 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -3847,6 +3847,7 @@ static int mvpp2_rx(struct mvpp2_port *port, struct 
napi_struct *napi,
struct mvpp2_pcpu_stats ps = {};
enum dma_data_direction dma_dir;
struct bpf_prog *xdp_prog;
+   struct xdp_rxq_info *rxqi;
struct xdp_buff xdp;
int rx_received;
int rx_done = 0;
@@ -3912,15 +3913,15 @@ static int mvpp2_rx(struct mvpp2_port *port, struct 
napi_struct *napi,
else
frag_size = bm_pool->frag_size;
 
-   if (xdp_prog) {
-   struct xdp_rxq_info *xdp_rxq;
+   if (bm_pool->pkt_size == MVPP2_BM_SHORT_PKT_SIZE)
+   rxqi = >xdp_rxq_short;
+   else
+   rxqi = >xdp_rxq_long;
 
-   if (bm_pool->pkt_size == MVPP2_BM_SHORT_PKT_SIZE)
-   xdp_rxq = >xdp_rxq_short;
-   else
-   xdp_rxq = >xdp_rxq_long;
+   if (xdp_prog) {
+   xdp.rxq = rxqi;
 
-   xdp_init_buff(, PAGE_SIZE, xdp_rxq);
+   xdp_init_buff(, PAGE_SIZE, rxqi);
xdp_prepare_buff(, data,
 MVPP2_MH_SIZE + MVPP2_SKB_HEADROOM,
 rx_bytes, false);
@@ -3964,7 +3965,7 @@ static int mvpp2_rx(struct mvpp2_port *port, struct 
napi_struct *napi,
}
 
if (pp)
-   page_pool_release_page(pp, virt_to_page(data));
+   skb_mark_for_recycle(skb, virt_to_page(data), 
>mem);
else
dma_unmap_single_attrs(dev->dev.parent, dma_addr,
   bm_pool->buf_size, 
DMA_FROM_DEVICE,
-- 
2.30.2



[PATCH net-next v2 3/5] page_pool: Allow drivers to hint on SKB recycling

2021-04-02 Thread Matteo Croce
From: Ilias Apalodimas 

Up to now several high speed NICs have custom mechanisms of recycling
the allocated memory they use for their payloads.
Our page_pool API already has recycling capabilities that are always
used when we are running in 'XDP mode'.  So let's tweak the API and the
kernel network stack slightly and allow the recycling to happen even
during the standard operation.
The API doesn't take into account 'split page' policies used by those
drivers currently, but can be extended once we have users for that.

The idea is to be able to intercept the packet on skb_release_data().
If it's a buffer coming from our page_pool API recycle it back to the
pool for further usage or just release the packet entirely.

To achieve that we introduce a bit in struct sk_buff (pp_recycle:1) and
store the xdp_mem_info in page->private.  Storing the information in
page->private allows us to recycle both SKBs and their fragments.
The SKB bit is needed for a couple of reasons. First of all in an
effort to affect the free path as less as possible, reading a single bit,
is better that trying to derive identical information for the page stored
data. Moreover page->private is used by skb_copy_ubufs.  We do have a
special mark in the page, that won't allow this to happen, but again
deciding without having to read the entire page is preferable.

The driver has to take care of the sync operations on it's own
during the buffer recycling since the buffer is, after opting-in to the
recycling, never unmapped.

Since the gain on the drivers depends on the architecture, we are not
enabling recycling by default if the page_pool API is used on a driver.
In order to enable recycling the driver must call skb_mark_for_recycle()
to store the information we need for recycling in page->private and
enabling the recycling bit, or page_pool_store_mem_info() for a fragment

Since we added an extra argument on __skb_frag_unref() to handle
recycling, update the current users of the function with that.

Co-developed-by: Jesper Dangaard Brouer 
Co-developed-by: Matteo Croce 
Signed-off-by: Ilias Apalodimas 
---
 .../chelsio/inline_crypto/ch_ktls/chcr_ktls.c |  2 +-
 drivers/net/ethernet/marvell/sky2.c   |  2 +-
 drivers/net/ethernet/mellanox/mlx4/en_rx.c|  2 +-
 include/linux/skbuff.h| 35 ---
 include/net/page_pool.h   | 13 ++
 include/net/xdp.h |  1 +
 net/core/page_pool.c  | 43 +++
 net/core/skbuff.c | 20 -
 net/core/xdp.c|  6 +++
 net/tls/tls_device.c  |  2 +-
 10 files changed, 115 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c 
b/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
index 1115b8f9ea4e..8f815ebb59ae 100644
--- a/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
+++ b/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
@@ -2125,7 +2125,7 @@ static int chcr_ktls_xmit(struct sk_buff *skb, struct 
net_device *dev)
/* clear the frag ref count which increased locally before */
for (i = 0; i < record->num_frags; i++) {
/* clear the frag ref count */
-   __skb_frag_unref(>frags[i]);
+   __skb_frag_unref(>frags[i], false);
}
/* if any failure, come out from the loop. */
if (ret) {
diff --git a/drivers/net/ethernet/marvell/sky2.c 
b/drivers/net/ethernet/marvell/sky2.c
index 68c154d715d6..9dc25c4fb359 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -2503,7 +2503,7 @@ static void skb_put_frags(struct sk_buff *skb, unsigned 
int hdr_space,
 
if (length == 0) {
/* don't need this page */
-   __skb_frag_unref(frag);
+   __skb_frag_unref(frag, false);
--skb_shinfo(skb)->nr_frags;
} else {
size = min(length, (unsigned) PAGE_SIZE);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c 
b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index e35e4d7ef4d1..cea62b8f554c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -526,7 +526,7 @@ static int mlx4_en_complete_rx_desc(struct mlx4_en_priv 
*priv,
 fail:
while (nr > 0) {
nr--;
-   __skb_frag_unref(skb_shinfo(skb)->frags + nr);
+   __skb_frag_unref(skb_shinfo(skb)->frags + nr, false);
}
return 0;
 }
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index c8def85fcc22..fffa6b35 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -40,6 +40,9 @@
 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
 #include 
 #endif

Re: [PATCH v6 00/21] Miscellaneous fixes for resctrl selftests

2021-04-02 Thread Fenghua Yu
Hi, Shuah,

On Fri, Apr 02, 2021 at 12:17:17PM -0600, Shuah Khan wrote:
> On 3/26/21 1:45 PM, Fenghua Yu wrote:
> > Hi, Shuah,
> > 
> > On Wed, Mar 17, 2021 at 02:22:34AM +, Fenghua Yu wrote:
> > > This patch set has several miscellaneous fixes to resctrl selftest tool
> > > that are easily visible to user. V1 had fixes to CAT test and CMT test
> > > but they were dropped in V2 because having them here made the patchset
> > > humongous. So, changes to CAT test and CMT test will be posted in another
> > > patchset.
> > > 
> > > Change Log:
> > > v6:
> > > - Add Tested-by: Babu Moger .
> > > - Replace "cat" by CAT_STR etc (Babu).
> > > - Capitalize the first letter of printed message (Babu).
> > 
> > Any comment on this series? Will you push it into linux-kselftest.git?
> > 
> Yes. Will apply for 5.13-rc1

Great! Thank you very much for your help!

-Fenghua


Re: [PATCH net-next v8 2/2] net: Add Qcom WWAN control driver

2021-04-02 Thread Loic Poulain
On Fri, 2 Apr 2021 at 17:43, Greg KH  wrote:
>
> On Fri, Apr 02, 2021 at 05:41:01PM +0200, Loic Poulain wrote:
> > On Fri, 2 Apr 2021 at 16:05, Greg KH  wrote:
> > >
> > > On Fri, Apr 02, 2021 at 04:06:37PM +0200, Loic Poulain wrote:
> > > > The MHI WWWAN control driver allows MHI QCOM-based modems to expose
> > > > different modem control protocols/ports via the WWAN framework, so that
> > > > userspace modem tools or daemon (e.g. ModemManager) can control WWAN
> > > > config and state (APN config, SMS, provider selection...). A QCOM-based
> > > > modem can expose one or several of the following protocols:
> > > > - AT: Well known AT commands interactive protocol (microcom, minicom...)
> > > > - MBIM: Mobile Broadband Interface Model (libmbim, mbimcli)
> > > > - QMI: QCOM MSM/Modem Interface (libqmi, qmicli)
> > > > - QCDM: QCOM Modem diagnostic interface (libqcdm)
> > > > - FIREHOSE: XML-based protocol for Modem firmware management
> > > > (qmi-firmware-update)
> > > >
> > > > Note that this patch is mostly a rework of the earlier MHI UCI
> > > > tentative that was a generic interface for accessing MHI bus from
> > > > userspace. As suggested, this new version is WWAN specific and is
> > > > dedicated to only expose channels used for controlling a modem, and
> > > > for which related opensource userpace support exist.
> > > >
> > > > Signed-off-by: Loic Poulain 
> > > > ---
> > > >  v2: update copyright (2021)
> > > >  v3: Move driver to dedicated drivers/net/wwan directory
> > > >  v4: Rework to use wwan framework instead of self cdev management
> > > >  v5: Fix errors/typos in Kconfig
> > > >  v6: - Move to new wwan interface, No need dedicated call to 
> > > > wwan_dev_create
> > > >  - Cleanup code (remove legacy from mhi_uci, unused defines/vars...)
> > > >  - Remove useless write_lock mutex
> > > >  - Add mhi_wwan_wait_writable and mhi_wwan_wait_dlqueue_lock_irq 
> > > > helpers
> > > >  - Rework locking
> > > >  - Add MHI_WWAN_TX_FULL flag
> > > >  - Add support for NONBLOCK read/write
> > > >  v7: Fix change log (mixed up 1/2 and 2/2)
> > > >  v8: - Implement wwan_port_ops (instead of fops)
> > > >  - Remove all mhi wwan data obsolete members (kref, lock, 
> > > > waitqueues)
> > > >  - Add tracking of RX buffer budget
> > > >  - Use WWAN TX flow control function to stop TX when MHI queue is 
> > > > full
> > > >
> > > >  drivers/net/wwan/Kconfig |  14 +++
> > > >  drivers/net/wwan/Makefile|   2 +
> > > >  drivers/net/wwan/mhi_wwan_ctrl.c | 253 
> > > > +++
> > > >  3 files changed, 269 insertions(+)
> > > >  create mode 100644 drivers/net/wwan/mhi_wwan_ctrl.c
> > > >
> > > > diff --git a/drivers/net/wwan/Kconfig b/drivers/net/wwan/Kconfig
> > > > index 545fe54..ce0bbfb 100644
> > > > --- a/drivers/net/wwan/Kconfig
> > > > +++ b/drivers/net/wwan/Kconfig
> > > > @@ -19,4 +19,18 @@ config WWAN_CORE
> > > > To compile this driver as a module, choose M here: the module 
> > > > will be
> > > > called wwan.
> > > >
> > > > +config MHI_WWAN_CTRL
> > > > + tristate "MHI WWAN control driver for QCOM-based PCIe modems"
> > > > + select WWAN_CORE
> > > > + depends on MHI_BUS
> > > > + help
> > > > +   MHI WWAN CTRL allows QCOM-based PCIe modems to expose different 
> > > > modem
> > > > +   control protocols/ports to userspace, including AT, MBIM, QMI, 
> > > > DIAG
> > > > +   and FIREHOSE. These protocols can be accessed directly from 
> > > > userspace
> > > > +   (e.g. AT commands) or via libraries/tools (e.g. libmbim, libqmi,
> > > > +   libqcdm...).
> > > > +
> > > > +   To compile this driver as a module, choose M here: the module 
> > > > will be
> > > > +   called mhi_wwan_ctrl
> > > > +
> > > >  endif # WWAN
> > > > diff --git a/drivers/net/wwan/Makefile b/drivers/net/wwan/Makefile
> > > > index 934590b..556cd90 100644
> > > > --- a/drivers/net/wwan/Makefile
> > > > +++ b/drivers/net/wwan/Makefile
> > > > @@ -5,3 +5,5 @@
> > > >
> > > >  obj-$(CONFIG_WWAN_CORE) += wwan.o
> > > >  wwan-objs += wwan_core.o
> > > > +
> > > > +obj-$(CONFIG_MHI_WWAN_CTRL) += mhi_wwan_ctrl.o
> > > > diff --git a/drivers/net/wwan/mhi_wwan_ctrl.c 
> > > > b/drivers/net/wwan/mhi_wwan_ctrl.c
> > > > new file mode 100644
> > > > index 000..f2fab23
> > > > --- /dev/null
> > > > +++ b/drivers/net/wwan/mhi_wwan_ctrl.c
> > > > @@ -0,0 +1,253 @@
> > > > +// SPDX-License-Identifier: GPL-2.0-only
> > > > +/* Copyright (c) 2021, Linaro Ltd  */
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +#include 
> > > > +
> > > > +/* MHI wwan flags */
> > > > +#define MHI_WWAN_DL_CAP  BIT(0)
> > > > +#define MHI_WWAN_UL_CAP  BIT(1)
> > > > +#define MHI_WWAN_STARTED BIT(2)
> > > > +
> > > > +#define MHI_WWAN_MAX_MTU 0x8000
> > > > +
> > > > +struct mhi_wwan_dev {
> > > > + /* Lower level is a mhi dev, upper level 

[PATCH net-next v2 2/5] mm: add a signature in struct page

2021-04-02 Thread Matteo Croce
From: Matteo Croce 

This is needed by the page_pool to avoid recycling a page not allocated
via page_pool.

Signed-off-by: Matteo Croce 
---
 include/linux/mm_types.h | 1 +
 include/net/page_pool.h  | 2 ++
 net/core/page_pool.c | 4 
 3 files changed, 7 insertions(+)

diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 6613b26a8894..ef2d0d5f62e4 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -101,6 +101,7 @@ struct page {
 * 32-bit architectures.
 */
dma_addr_t dma_addr;
+   unsigned long signature;
};
struct {/* slab, slob and slub */
union {
diff --git a/include/net/page_pool.h b/include/net/page_pool.h
index b5b195305346..b30405e84b5e 100644
--- a/include/net/page_pool.h
+++ b/include/net/page_pool.h
@@ -63,6 +63,8 @@
  */
 #define PP_ALLOC_CACHE_SIZE128
 #define PP_ALLOC_CACHE_REFILL  64
+#define PP_SIGNATURE   0x20210303
+
 struct pp_alloc_cache {
u32 count;
void *cache[PP_ALLOC_CACHE_SIZE];
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index ad8b0707af04..2ae9b554ef98 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -232,6 +232,8 @@ static struct page *__page_pool_alloc_pages_slow(struct 
page_pool *pool,
page_pool_dma_sync_for_device(pool, page, pool->p.max_len);
 
 skip_dma_map:
+   page->signature = PP_SIGNATURE;
+
/* Track how many pages are held 'in-flight' */
pool->pages_state_hold_cnt++;
 
@@ -302,6 +304,8 @@ void page_pool_release_page(struct page_pool *pool, struct 
page *page)
 DMA_ATTR_SKIP_CPU_SYNC);
page->dma_addr = 0;
 skip_dma_unmap:
+   page->signature = 0;
+
/* This may be the last page returned, releasing the pool, so
 * it is not safe to reference pool afterwards.
 */
-- 
2.30.2



[PATCH net-next v2 1/5] xdp: reduce size of struct xdp_mem_info

2021-04-02 Thread Matteo Croce
From: Jesper Dangaard Brouer 

It is possible to compress/reduce the size of struct xdp_mem_info.
This change reduce struct xdp_mem_info from 8 bytes to 4 bytes.

The member xdp_mem_info.id can be reduced to u16, as the mem_id_ht
rhashtable in net/core/xdp.c is already limited by MEM_ID_MAX=0xFFFE
which can safely fit in u16.

The member xdp_mem_info.type could be reduced more than u16, as it stores
the enum xdp_mem_type, but due to alignment it is only reduced to u16.

Signed-off-by: Jesper Dangaard Brouer 
---
 include/net/xdp.h | 4 ++--
 net/core/xdp.c| 8 
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/net/xdp.h b/include/net/xdp.h
index a5bc214a49d9..c35864d59113 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -48,8 +48,8 @@ enum xdp_mem_type {
 #define XDP_XMIT_FLAGS_MASKXDP_XMIT_FLUSH
 
 struct xdp_mem_info {
-   u32 type; /* enum xdp_mem_type, but known size type */
-   u32 id;
+   u16 type; /* enum xdp_mem_type, but known size type */
+   u16 id;
 };
 
 struct page_pool;
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 05354976c1fc..3dd47ed83778 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -35,11 +35,11 @@ static struct rhashtable *mem_id_ht;
 
 static u32 xdp_mem_id_hashfn(const void *data, u32 len, u32 seed)
 {
-   const u32 *k = data;
-   const u32 key = *k;
+   const u16 *k = data;
+   const u16 key = *k;
 
BUILD_BUG_ON(sizeof_field(struct xdp_mem_allocator, mem.id)
-!= sizeof(u32));
+!= sizeof(u16));
 
/* Use cyclic increasing ID as direct hash key */
return key;
@@ -49,7 +49,7 @@ static int xdp_mem_id_cmp(struct rhashtable_compare_arg *arg,
  const void *ptr)
 {
const struct xdp_mem_allocator *xa = ptr;
-   u32 mem_id = *(u32 *)arg->key;
+   u16 mem_id = *(u16 *)arg->key;
 
return xa->mem.id != mem_id;
 }
-- 
2.30.2



Re: [PATCH 0/4] mm/page_reporting: Some knobs and fixes

2021-04-02 Thread Alexander Duyck
On Thu, Apr 1, 2021 at 9:09 PM Xunlei Pang  wrote:
>
> On 3/26/21 5:44 PM, Xunlei Pang wrote:
> > Add the following knobs in PATCH 1~3:
> >  /sys/kernel/mm/page_reporting/reported_kbytes
> >  /sys/kernel/mm/page_reporting/refault_kbytes
> >  /sys/kernel/mm/page_reporting/reporting_factor
> >
> > Fix unexpected user OOM in PATCH 4.
> >
> > Xunlei Pang (4):
> >   mm/page_reporting: Introduce free page reported counters
> >   mm/page_reporting: Introduce free page reporting factor
> >   mm/page_reporting: Introduce "page_reporting_factor=" boot parameter
> >   mm/page_reporting: Fix possible user allocation failure
> >
> >  Documentation/admin-guide/kernel-parameters.txt |   3 +
> >  include/linux/mmzone.h  |   3 +
> >  mm/page_alloc.c |   6 +-
> >  mm/page_reporting.c | 268 
> > ++--
> >  4 files changed, 260 insertions(+), 20 deletions(-)
> >
>
> Hi guys,
>
> Looks "Alexander Duyck " was not
> available, so Cced more, any comment?
>
> Thanks!

Yes, my Intel account has been offline since October. If you need to
reach me, my gmail is the best way to go.

As far as the patch series itself I am not exactly thrilled with it.
There seems to be a number of spots where things are being changed
such that the CPU overhead will be much more significant.

The cover page should actually say what the patch set is attempting to
accomplish. In the patch descriptions you have told us what you are
doing, but the why isn't completely clear. For example I am not sure
if the issue addressed in patch 4 was present before patches 1-3 were
introduced.


[PATCH net-next v2 0/5] page_pool: recycle buffers

2021-04-02 Thread Matteo Croce
From: Matteo Croce 

This is a respin of [1]

This  patchset shows the plans for allowing page_pool to handle and
maintain DMA map/unmap of the pages it serves to the driver.  For this
to work a return hook in the network core is introduced.

The overall purpose is to simplify drivers, by providing a page
allocation API that does recycling, such that each driver doesn't have
to reinvent its own recycling scheme.  Using page_pool in a driver
does not require implementing XDP support, but it makes it trivially
easy to do so.  Instead of allocating buffers specifically for SKBs
we now allocate a generic buffer and either wrap it on an SKB
(via build_skb) or create an XDP frame.
The recycling code leverages the XDP recycle APIs.

The Marvell mvpp2 and mvneta drivers are used in this patchset to
demonstrate how to use the API, and tested on a MacchiatoBIN
and EspressoBIN boards respectively.

[1] 
https://lore.kernel.org/netdev/154413868810.21735.572808840657728172.stgit@firesoul/

v1 -> v2:
- fix a commit message
- avoid setting pp_recycle multiple times on mvneta
- squash two patches to avoid breaking bisect

Ilias Apalodimas (1):
  page_pool: Allow drivers to hint on SKB recycling

Jesper Dangaard Brouer (1):
  xdp: reduce size of struct xdp_mem_info

Matteo Croce (3):
  mm: add a signature in struct page
  mvpp2: recycle buffers
  mvneta: recycle buffers

 .../chelsio/inline_crypto/ch_ktls/chcr_ktls.c |  2 +-
 drivers/net/ethernet/marvell/mvneta.c |  7 ++-
 .../net/ethernet/marvell/mvpp2/mvpp2_main.c   | 17 +++
 drivers/net/ethernet/marvell/sky2.c   |  2 +-
 drivers/net/ethernet/mellanox/mlx4/en_rx.c|  2 +-
 include/linux/mm_types.h  |  1 +
 include/linux/skbuff.h| 35 --
 include/net/page_pool.h   | 15 ++
 include/net/xdp.h |  5 +-
 net/core/page_pool.c  | 47 +++
 net/core/skbuff.c | 20 +++-
 net/core/xdp.c| 14 --
 net/tls/tls_device.c  |  2 +-
 13 files changed, 142 insertions(+), 27 deletions(-)

-- 
2.30.2



Re: [RFC v2] KVM: x86: Support KVM VMs sharing SEV context

2021-04-02 Thread Sean Christopherson
On Tue, Mar 16, 2021, Nathan Tempelman wrote:
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 874ea309279f..b2c90c67a0d9 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -66,6 +66,11 @@ static int sev_flush_asids(void)
>   return ret;
>  }
>  
> +static inline bool is_mirroring_enc_context(struct kvm *kvm)
> +{
> + return to_kvm_svm(kvm)->sev_info.enc_context_owner;

This is one of the few times where I actually think "!!" would be helpful.

> +}
> +
>  /* Must be called with the sev_bitmap_lock held */
>  static bool __sev_recycle_asids(int min_asid, int max_asid)
>  {
> @@ -1124,6 +1129,10 @@ int svm_mem_enc_op(struct kvm *kvm, void __user *argp)
>   if (copy_from_user(_cmd, argp, sizeof(struct kvm_sev_cmd)))
>   return -EFAULT;
>  
> + /* enc_context_owner handles all memory enc operations */
> + if (is_mirroring_enc_context(kvm))

This needs to be checked after acquiring kvm->lock to avoid TOCTOU.

> + return -ENOTTY;

-ENOTTY doesn't seem right, -EINVAL feels more appropriate.

> +
>   mutex_lock(>lock);
>  
>   switch (sev_cmd.id) {
> @@ -1186,6 +1195,10 @@ int svm_register_enc_region(struct kvm *kvm,
>   if (!sev_guest(kvm))
>   return -ENOTTY;
>  
> + /* If kvm is mirroring encryption context it isn't responsible for it */
> + if (is_mirroring_enc_context(kvm))
> + return -ENOTTY;

Same comment about -ENOTTY vs. -EINVAL.

> +
>   if (range->addr > ULONG_MAX || range->size > ULONG_MAX)
>   return -EINVAL;
>  
> @@ -1252,6 +1265,10 @@ int svm_unregister_enc_region(struct kvm *kvm,
>   struct enc_region *region;
>   int ret;
>  
> + /* If kvm is mirroring encryption context it isn't responsible for it */
> + if (is_mirroring_enc_context(kvm))
> + return -ENOTTY;
> +
>   mutex_lock(>lock);
>  
>   if (!sev_guest(kvm)) {
> @@ -1282,6 +1299,71 @@ int svm_unregister_enc_region(struct kvm *kvm,
>   return ret;
>  }
>  
> +int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd)
> +{
> + struct file *source_kvm_file;
> + struct kvm *source_kvm;
> + struct kvm_sev_info *mirror_sev;

Can we just call this "sev" to match "kvm".  If there's ever confusion, the
source can be "source_sev".

> + unsigned int asid;
> + int ret;
> +
> + source_kvm_file = fget(source_fd);
> + if (!file_is_kvm(source_kvm_file)) {
> + ret = -EBADF;
> + goto e_source_put;
> + }
> +
> + source_kvm = source_kvm_file->private_data;
> + mutex_lock(_kvm->lock);
> +
> + if (!sev_guest(source_kvm)) {
> + ret = -ENOTTY;
> + goto e_source_unlock;
> + }
> +
> + /* Mirrors of mirrors should work, but let's not get silly */
> + if (is_mirroring_enc_context(source_kvm) || source_kvm == kvm) {
> + ret = -ENOTTY;

Again, -ENOTTY does not feel right, especially for the "source_kvm == kvm" case.

> + goto e_source_unlock;
> + }
> +
> + asid = to_kvm_svm(source_kvm)->sev_info.asid;
> +
> + /*
> +  * The mirror kvm holds an enc_context_owner ref so its asid can't
> +  * disappear until we're done with it
> +  */
> + kvm_get_kvm(source_kvm);

My comment from before still stands; why can't we simply keep source_kvm_file?

> +
> + fput(source_kvm_file);
> + mutex_unlock(_kvm->lock);
> + mutex_lock(>lock);
> +
> + if (sev_guest(kvm)) {
> + ret = -ENOTTY;

-EINVAL again?

> + goto e_mirror_unlock;
> + }
> +
> + /* Set enc_context_owner and copy its encryption context over */
> + mirror_sev = _kvm_svm(kvm)->sev_info;
> + mirror_sev->enc_context_owner = source_kvm;
> + mirror_sev->asid = asid;
> + mirror_sev->active = true;
> +
> + mutex_unlock(>lock);
> + return 0;
> +
> +e_mirror_unlock:
> + mutex_unlock(>lock);
> + kvm_put_kvm(source_kvm);
> + return ret;
> +e_source_unlock:
> + mutex_unlock(_kvm->lock);
> +e_source_put:
> + fput(source_kvm_file);
> + return ret;
> +}
> +
>  void sev_vm_destroy(struct kvm *kvm)
>  {
>   struct kvm_sev_info *sev = _kvm_svm(kvm)->sev_info;
> @@ -1293,6 +1375,12 @@ void sev_vm_destroy(struct kvm *kvm)
>  
>   mutex_lock(>lock);
>  
> + /* If this is a mirror_kvm release the enc_context_owner and skip sev 
> cleanup */
> + if (is_mirroring_enc_context(kvm)) {
> + kvm_put_kvm(sev->enc_context_owner);
> + return;

This returns without dropping kvm->lock.  This is the last reference to the VM,
so it should be safe to simply do this out of the lock.  I actually don't know
why this function takes the lock in the first place, AFAICT there is nothing
else that can conflict.

> + }
> +
>   /*
>* Ensure that all guest tagged cache entries are flushed before
>* releasing the pages back to the system for use. CLFLUSH will
> diff 

Re: [PATCH] lib/string: Introduce sysfs_streqcase

2021-04-02 Thread Nick Desaulniers
Thanks for the patch!

+ akpm (please remember to run ./scripts/get_maintainer.pl on your patch files)

On Fri, Apr 2, 2021 at 2:41 AM Gioh Kim  wrote:
>
> As the name shows, it checks if strings are equal in case insensitive
> manner. I found some cases using strncasecmp to check the entire
> strings and they would not work as intended.
>
> For example, drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c uses
> strncasecmp to check that the input via sysfs is "mi". But it would
> work even-if the input is "min-wrongcommand".
> And also drivers/pnp/interface.c checks "disable" command with
> strncasecmp but it would also work if the command is "disable-wrong".

Perhaps those callers should be using strcasecmp then, rather than strncasecmp?

Also, if they're being liberal in accepting either case, I don't see
why the sysfs nodes should be strict in rejecting trailing input at
that point.

>
> Signed-off-by: Gioh Kim 
> ---
>  lib/string.c | 23 +++
>  1 file changed, 23 insertions(+)
>
> diff --git a/lib/string.c b/lib/string.c
> index 7548eb715ddb..5e6bc0d3d5c6 100644
> --- a/lib/string.c
> +++ b/lib/string.c
> @@ -714,6 +714,29 @@ bool sysfs_streq(const char *s1, const char *s2)
>  }
>  EXPORT_SYMBOL(sysfs_streq);
>
> +/**
> + * sysfs_streqcase - same to sysfs_streq and case insensitive
> + * @s1: one string
> + * @s2: another string
> + *
> + */
> +bool sysfs_streqcase(const char *s1, const char *s2)
> +{
> +   while (*s1 && tolower(*s1) == tolower(*s2)) {
> +   s1++;
> +   s2++;
> +   }
> +
> +   if (*s1 == *s2)
> +   return true;
> +   if (!*s1 && *s2 == '\n' && !s2[1])
> +   return true;
> +   if (*s1 == '\n' && !s1[1] && !*s2)
> +   return true;
> +   return false;
> +}
> +EXPORT_SYMBOL(sysfs_streqcase);

This should be declared in
include/linux/string.h
in order for others to use this (as 0day bot notes).

> +
>  /**
>   * match_string - matches given string in an array
>   * @array: array of strings
> --
> 2.25.1
>


--
Thanks,
~Nick Desaulniers


Re: [PATCH v6 00/21] Miscellaneous fixes for resctrl selftests

2021-04-02 Thread Shuah Khan

On 3/26/21 1:45 PM, Fenghua Yu wrote:

Hi, Shuah,

On Wed, Mar 17, 2021 at 02:22:34AM +, Fenghua Yu wrote:

This patch set has several miscellaneous fixes to resctrl selftest tool
that are easily visible to user. V1 had fixes to CAT test and CMT test
but they were dropped in V2 because having them here made the patchset
humongous. So, changes to CAT test and CMT test will be posted in another
patchset.

Change Log:
v6:
- Add Tested-by: Babu Moger .
- Replace "cat" by CAT_STR etc (Babu).
- Capitalize the first letter of printed message (Babu).


Any comment on this series? Will you push it into linux-kselftest.git?


Yes. Will apply for 5.13-rc1

thanks,
-- Shuah


Re: [PATCH v2 3/6] soc: actions: Add Actions Semi Owl socinfo driver

2021-04-02 Thread Manivannan Sadhasivam
On Tue, Mar 30, 2021 at 04:48:18PM +0300, Cristian Ciocaltea wrote:
> The driver provides information about the Action Semi Owl family of
> SoCs (S500, S700 and S900) to user space via sysfs: machine, family,
> soc_id, serial_number.
> 
> Note the serial number is currently provided only for the S500 SoC
> variant.
> 
> Signed-off-by: Cristian Ciocaltea 
> ---
>  drivers/soc/actions/Kconfig   |   8 +
>  drivers/soc/actions/Makefile  |   1 +
>  drivers/soc/actions/owl-socinfo.c | 152 ++
>  include/linux/soc/actions/owl-serial-number.h |  20 +++
>  4 files changed, 181 insertions(+)
>  create mode 100644 drivers/soc/actions/owl-socinfo.c
>  create mode 100644 include/linux/soc/actions/owl-serial-number.h
> 
> diff --git a/drivers/soc/actions/Kconfig b/drivers/soc/actions/Kconfig
> index 1aca2058a40c..15faade9282d 100644
> --- a/drivers/soc/actions/Kconfig
> +++ b/drivers/soc/actions/Kconfig
> @@ -14,4 +14,12 @@ config OWL_PM_DOMAINS
> power-gating on Actions Semiconductor S500, S700 and S900 SoCs.
> If unsure, say 'n'.
>  
> +config OWL_SOCINFO
> + bool "Actions Semi Owl SoC info driver"
> + default ARCH_ACTIONS
> + select SOC_BUS
> + help
> +   Say 'y' here to support the Action Semiconductor Owl socinfo

Actions Semi

> +   driver, providing information about the SoC to user space.
> +
>  endif
> diff --git a/drivers/soc/actions/Makefile b/drivers/soc/actions/Makefile
> index 4db9e7b050e5..4b2591d3089f 100644
> --- a/drivers/soc/actions/Makefile
> +++ b/drivers/soc/actions/Makefile
> @@ -2,3 +2,4 @@
>  
>  obj-$(CONFIG_OWL_PM_DOMAINS_HELPER) += owl-sps-helper.o
>  obj-$(CONFIG_OWL_PM_DOMAINS) += owl-sps.o
> +obj-$(CONFIG_OWL_SOCINFO) += owl-socinfo.o
> diff --git a/drivers/soc/actions/owl-socinfo.c 
> b/drivers/soc/actions/owl-socinfo.c
> new file mode 100644
> index ..f28eafac3792
> --- /dev/null
> +++ b/drivers/soc/actions/owl-socinfo.c
> @@ -0,0 +1,152 @@

[...]

> + * Access SoC's serial number stored by the bootloader in DDR memory.
> + */
> +static int owl_socinfo_read_serial_rmem(struct device *dev)
> +{
> + struct reserved_mem *rmem;
> + struct device_node *np;
> + int ret = 0;
> +
> + np = of_find_compatible_node(NULL, NULL, "actions,owl-soc-serial");
> + if (!np)
> + return -ENXIO;
> +
> + rmem = of_reserved_mem_lookup(np);

If you do this correctly, you could use "pdev->dev.of_node" here instead of
using "of_find_compatible_node()" for getting np.

> + if (!rmem) {
> + dev_err(dev, "failed to acquire reserved memory region\n");
> + ret = -EINVAL;
> + goto out_put;
> + }
> +

[...]

> +static const struct of_device_id owl_socinfo_of_match[] = {
> + { .compatible = "actions,s500-soc", .data = _soc_info, },
> + { .compatible = "actions,s700-soc", .data = _soc_info, },
> + { .compatible = "actions,s900-soc", .data = _soc_info, },

Please don't add S700/S900 for now.

> + { }
> +};
> +
> +static struct platform_driver owl_socinfo_platform_driver = {
> + .probe = owl_socinfo_probe,
> + .driver = {
> + .name = "owl-socinfo",
> + .of_match_table = owl_socinfo_of_match,
> + },
> +};
> +
> +static int __init owl_socinfo_init(void)
> +{
> + return platform_driver_register(_socinfo_platform_driver);
> +}
> +subsys_initcall(owl_socinfo_init);
> diff --git a/include/linux/soc/actions/owl-serial-number.h 
> b/include/linux/soc/actions/owl-serial-number.h
> new file mode 100644
> index ..f8595417668f
> --- /dev/null
> +++ b/include/linux/soc/actions/owl-serial-number.h
> @@ -0,0 +1,20 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright (c) 2021 Cristian Ciocaltea 
> + */
> +
> +#ifndef __SOC_ACTIONS_OWL_SERIAL_NUMBER_H__
> +#define __SOC_ACTIONS_OWL_SERIAL_NUMBER_H__
> +
> +#if IS_ENABLED(CONFIG_OWL_SOCINFO)
> +u32 owl_get_soc_serial_low(void);
> +u32 owl_get_soc_serial_high(void);

Where are these APIs used?

Thanks,
Mani

> +#else
> +static inline u32 owl_get_soc_serial_low(void)
> +{ return 0; }
> +
> +static inline u32 owl_get_soc_serial_high(void)
> +{ return 0; }
> +#endif /* CONFIG_OWL_SOCINFO */
> +
> +#endif /* __SOC_ACTIONS_OWL_SERIAL_NUMBER_H__ */
> -- 
> 2.31.1
> 


Re: [PATCH v1 0/2] Add imx8m power domain driver

2021-04-02 Thread Adrien Grassein
Le ven. 2 avr. 2021 à 19:58, Abel Vesa  a écrit :
>
> On 21-04-02 19:48:41, Adrien Grassein wrote:
> > Hi,
> >
> > Le ven. 2 avr. 2021 à 19:42, Abel Vesa  a écrit :
> > >
> > > On 21-04-02 18:45:04, Adrien Grassein wrote:
> > > > Hi,
> > > >
> > > > this patch et aims to add the support of the i.MX 8 Power Domain driver.
> > > > Some devices (like usbotg2) can't work without this patch as their
> > > > attached power domain are down.
> > > >
> > > > The original drivr was taken from le imx kernel and aapted to fit with
> > > > the actual mainline (minor fixes).
> > > >
> > > > Thanks,
> > > >
> > >
> > > Big NACK for the whole series.
> > >
> > > This approach has already been rejected upstream.
> >
> > So what is the correct approach?
> > At this point otg2 node of imx8mm is not working at all (and blocks the 
> > whole
> > boot of the kernel)
> >
>
> Have a look at this thread:
>
> https://lkml.org/lkml/2020/4/27/706
>
Understood, so I will try to update the gpc driver (at least for otg).

> > >
> > > Plus, you changed the original author, this work was originally done by 
> > > Jacky Bai.
> >
> > I have not changed this, the original author is not mentioned on the
> > original patch.
>
> Here is the original commit:
>
> https://github.com/Freescale/linux-fslc/commit/7ebcf5ccf423afe4ccd9c53ef204018b0b653ce0
>
>
> >
> > >
> > > > Adrien Grassein (2):
> > > >   dt-bindings: power: Add documentation for imx8m power domain driver
> > > >   soc: imx: add Power Domain driver for i.MX8M(M|N|P)
> > > >
> > > >  .../bindings/power/fsl,imx-power-domain.yaml  |  89 +++
> > > >  MAINTAINERS   |  10 +
> > > >  drivers/soc/imx/Kconfig   |   7 +
> > > >  drivers/soc/imx/Makefile  |   1 +
> > > >  drivers/soc/imx/imx8m_pm_domains.c| 233 ++
> > > >  include/dt-bindings/power/imx8mm-power.h  |  21 ++
> > > >  include/dt-bindings/power/imx8mn-power.h  |  15 ++
> > > >  include/dt-bindings/power/imx8mp-power.h  |  28 +++
> > > >  include/soc/imx/imx_sip.h |  12 +
> > > >  9 files changed, 416 insertions(+)
> > > >  create mode 100644 
> > > > Documentation/devicetree/bindings/power/fsl,imx-power-domain.yaml
> > > >  create mode 100644 drivers/soc/imx/imx8m_pm_domains.c
> > > >  create mode 100644 include/dt-bindings/power/imx8mm-power.h
> > > >  create mode 100644 include/dt-bindings/power/imx8mn-power.h
> > > >  create mode 100644 include/dt-bindings/power/imx8mp-power.h
> > > >  create mode 100644 include/soc/imx/imx_sip.h
> > > >
> > > > --
> > > > 2.25.1
> > > >
> >
> > Thanks,

Thanks,


Re: [PATCH v2] psi: allow unprivileged users with CAP_SYS_RESOURCE to write psi files

2021-04-02 Thread Kees Cook
On Thu, Apr 01, 2021 at 10:58:33PM -0400, Josh Hunt wrote:
> Currently only root can write files under /proc/pressure. Relax this to
> allow tasks running as unprivileged users with CAP_SYS_RESOURCE to be
> able to write to these files.
> 
> Signed-off-by: Josh Hunt 

Reviewed-by: Kees Cook 

-- 
Kees Cook


Re: [PATCH] net: initialize local variables in net/ipv6/mcast.c and net/ipv4/igmp.c

2021-04-02 Thread Phillip Potter
On Fri, Apr 02, 2021 at 07:49:44PM +0200, Eric Dumazet wrote:
> 
> 
> On 4/2/21 7:36 PM, Phillip Potter wrote:
> > Use memset to initialize two local buffers in net/ipv6/mcast.c,
> > and another in net/ipv4/igmp.c. Fixes a KMSAN found uninit-value
> > bug reported by syzbot at:
> > https://syzkaller.appspot.com/bug?id=0766d38c656abeace60621896d705743aeefed51
> 
> 
> According to this link, the bug no longer triggers.
> 
> Please explain why you think it is still there.
> 

Dear Eric,

It definitely still triggers, tested it on the master branch of
https://github.com/google/kmsan last night. The patch which fixes the
crash on that page is the same patch I've sent in.

Regards,
Phil


Re: [PATCH v5 00/21] Miscellaneous fixes for resctrl selftests

2021-04-02 Thread Shuah Khan

On 3/12/21 3:11 PM, Fenghua Yu wrote:

Hi, Babu,

On Fri, Mar 12, 2021 at 01:08:11PM -0600, Babu Moger wrote:

Hi Fenghua, Thanks for the patches.
Sanity tested them on AMD systems. Appears to work fine.
Few minor comments in few patches.
Tested-by: Babu Moger 


I will add Tested-by: Babu Moger in the series and address your
comments.

Thank you for your review!



Looks like a few patches in this series needs updates. Do you plan to
send the new revision for consideration for 5.13?

thanks,
-- Shuah


Re: [PATCH v2 1/6] dt-bindings: reserved-memory: Add Owl SoC serial number binding

2021-04-02 Thread Manivannan Sadhasivam
On Thu, Apr 01, 2021 at 08:40:01PM +0300, Cristian Ciocaltea wrote:
> On Thu, Apr 01, 2021 at 12:07:04PM -0500, Rob Herring wrote:
> > On Tue, Mar 30, 2021 at 04:48:16PM +0300, Cristian Ciocaltea wrote:
> > > Add devicetree binding for the Actions Semi Owl SoC serial number
> > > reserved-memory range.
> > > 
> > > Signed-off-by: Cristian Ciocaltea 
> > > ---
> > >  .../actions,owl-soc-serial.yaml   | 53 +++
> > >  1 file changed, 53 insertions(+)
> > >  create mode 100644 
> > > Documentation/devicetree/bindings/reserved-memory/actions,owl-soc-serial.yaml
> > > 
> > > diff --git 
> > > a/Documentation/devicetree/bindings/reserved-memory/actions,owl-soc-serial.yaml
> > >  
> > > b/Documentation/devicetree/bindings/reserved-memory/actions,owl-soc-serial.yaml
> > > new file mode 100644
> > > index ..41b71f47ee6c
> > > --- /dev/null
> > > +++ 
> > > b/Documentation/devicetree/bindings/reserved-memory/actions,owl-soc-serial.yaml
> > > @@ -0,0 +1,53 @@
> > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > > +%YAML 1.2
> > > +---
> > > +$id: 
> > > http://devicetree.org/schemas/reserved-memory/actions,owl-soc-serial.yaml#
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: Actions Semi Owl reserved-memory for SoC serial number
> > > +
> > > +maintainers:
> > > +  - Cristian Ciocaltea 
> > > +
> > > +description: |
> > > +  Provide access to the memory region where the two parts of the Actions
> > > +  Semi Owl SoC serial number (low & high) can be read from. This 
> > > information
> > > +  is provided by the bootloader, hence expose it under /reserved-memory 
> > > node.
> > > +
> > > +  Please refer to reserved-memory.txt in this directory for common 
> > > binding
> > > +  part and usage.
> > > +
> > > +  This is currently supported only on the S500 SoC variant.
> > > +
> > > +properties:
> > > +  compatible:
> > > +oneOf:
> > > +  - const: actions,owl-soc-serial
> > > +  - items:
> > > +  - enum:
> > > +  - actions,s500-soc-serial
> > > +  - const: actions,owl-soc-serial
> > > +
> > > +  reg:
> > > +maxItems: 1
> > > +
> > > +required:
> > > +  - compatible
> > > +  - reg
> > > +
> > > +additionalProperties: true
> > > +
> > > +examples:
> > > +  - |
> > > +reserved-memory {
> > > +#address-cells = <1>;
> > > +#size-cells = <1>;
> > > +ranges;
> > > +
> > > +soc_serial: soc-serial@800 {
> > > +compatible = "actions,s500-soc-serial", 
> > > "actions,owl-soc-serial";
> > > +reg = <0x800 0x8>;
> > 
> > You end up wasting a whole page of memory for 8 bytes. It may be better 
> > to copy this to a DT property ('serial-number' is already a defined root 
> > property).
> 
> Actually there is more information provided by the vendor bootloader

Then you should call it as socinfo or something not soc_serial.

Thanks,
Mani

> in this memory page, so we might use it once we are able to decode it.
> For the moment I could only identify the serial number.
> 
> Thanks,
> Cristi
> 
> > Rob


Re: [PATCH net v2] atl1c: move tx cleanup processing out of interrupt

2021-04-02 Thread Eric Dumazet



On 4/2/21 7:20 PM, Gatis Peisenieks wrote:
> Tx queue cleanup happens in interrupt handler on same core as rx queue 
> processing.
> Both can take considerable amount of processing in high packet-per-second 
> scenarios.
> 
> Sending big amounts of packets can stall the rx processing which is unfair
> and also can lead to to out-of-memory condition since __dev_kfree_skb_irq
> queues the skbs for later kfree in softirq which is not allowed to happen
> with heavy load in interrupt handler.
> 
> This puts tx cleanup in its own napi and enables threaded napi to allow the 
> rx/tx
> queue processing to happen on different cores.
> 
> The ability to sustain equal amounts of tx/rx traffic increased:
> from 280Kpps to 1130Kpps on Threadripper 3960X with upcoming Mikrotik 10/25G 
> NIC,
> from 520Kpps to 850Kpps on Intel i3-3320 with Mikrotik RB44Ge adapter.
> 
> Signed-off-by: Gatis Peisenieks 
> ---
>  drivers/net/ethernet/atheros/atl1c/atl1c.h    |  2 +
>  .../net/ethernet/atheros/atl1c/atl1c_main.c   | 43 +--
>  2 files changed, 41 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c.h 
> b/drivers/net/ethernet/atheros/atl1c/atl1c.h
> index a0562a90fb6d..4404fa44d719 100644
> --- a/drivers/net/ethernet/atheros/atl1c/atl1c.h
> +++ b/drivers/net/ethernet/atheros/atl1c/atl1c.h
> @@ -506,6 +506,7 @@ struct atl1c_adapter {
>  struct net_device   *netdev;
>  struct pci_dev  *pdev;
>  struct napi_struct  napi;
> +    struct napi_struct  tx_napi;
>  struct page *rx_page;
>  unsigned int    rx_page_offset;
>  unsigned int    rx_frag_size;
> @@ -529,6 +530,7 @@ struct atl1c_adapter {
>  u16 link_duplex;
> 
>  spinlock_t mdio_lock;
> +    spinlock_t irq_mask_lock;
>  atomic_t irq_sem;
> 
>  struct work_struct common_task;
> diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c 
> b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> index 3f65f2b370c5..f51b28e8b6dc 100644
> --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> @@ -813,6 +813,7 @@ static int atl1c_sw_init(struct atl1c_adapter *adapter)
>  atl1c_set_rxbufsize(adapter, adapter->netdev);
>  atomic_set(>irq_sem, 1);
>  spin_lock_init(>mdio_lock);
> +    spin_lock_init(>irq_mask_lock);
>  set_bit(__AT_DOWN, >flags);
> 
>  return 0;
> @@ -1530,7 +1531,7 @@ static inline void atl1c_clear_phy_int(struct 
> atl1c_adapter *adapter)
>  spin_unlock(>mdio_lock);
>  }
> 
> -static bool atl1c_clean_tx_irq(struct atl1c_adapter *adapter,
> +static unsigned atl1c_clean_tx_irq(struct atl1c_adapter *adapter,
>  enum atl1c_trans_queue type)


This v2 is much better, thanks.

You might rename this atl1c_clean_tx_irq(), because it is now
not run under hard irqs ?

Maybe merge atl1c_clean_tx_irq() and atl1c_clean_tx() into a single function ?




Re: [PATCH v2 2/6] dt-bindings: soc: actions: Add Actions Semi Owl socinfo binding

2021-04-02 Thread Manivannan Sadhasivam
On Tue, Mar 30, 2021 at 04:48:17PM +0300, Cristian Ciocaltea wrote:
> Add devicetree binding for the Actions Semi Owl socinfo driver.
> 

Devicetree binding shouldn't be added for a driver instead for an IP or hw.

> Signed-off-by: Cristian Ciocaltea 
> ---
>  .../bindings/soc/actions/owl-socinfo.yaml | 57 +++
>  1 file changed, 57 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/soc/actions/owl-socinfo.yaml
> 
> diff --git a/Documentation/devicetree/bindings/soc/actions/owl-socinfo.yaml 
> b/Documentation/devicetree/bindings/soc/actions/owl-socinfo.yaml
> new file mode 100644
> index ..01e4a8b4f5ac
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/soc/actions/owl-socinfo.yaml
> @@ -0,0 +1,57 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/soc/actions/owl-socinfo.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Actions Semi Owl SoC info module
> +
> +maintainers:
> +  - Cristian Ciocaltea 
> +
> +description: |
> +  Actions Semi Owl SoC info module provides access to various information
> +  about the S500, S700 and S900 SoC variants, such as serial number or id.
> +

S700/S900 are not yet confirmed, so please avoid them.

> +select:
> +  properties:
> +compatible:
> +  contains:
> +enum:
> +  - actions,s500-soc
> +  - actions,s700-soc
> +  - actions,s900-soc
> +  required:
> +- compatible
> +
> +properties:
> +  compatible:
> +items:
> +  - enum:
> +  - actions,s500-soc
> +  - actions,s700-soc
> +  - actions,s900-soc
> +  - const: simple-bus
> +
> +required:
> +  - compatible
> +
> +additionalProperties: true
> +
> +examples:
> +  - |
> +/ {
> +compatible = "roseapplepi,roseapplepi", "actions,s500";
> +model = "Roseapple Pi";
> +#address-cells = <1>;
> +#size-cells = <1>;
> +
> +soc {
> +compatible = "actions,s500-soc", "simple-bus";

No. This shouldn't fall under /soc. I think you should added a separate
compatible for the reserved memory itself and add a corresponding socinfo
driver under drivers/soc.

This way it is obvious that the information is contained in a memory region and
a driver is used for parsing that.

Thanks,
Mani

> +#address-cells = <1>;
> +#size-cells = <1>;
> +ranges;
> +};
> +};
> +
> +...
> -- 
> 2.31.1
> 


Re: fs/gfs2/rgrp.c:1772:53: warning: Possible null pointer dereference: minext [nullPointer]

2021-04-02 Thread Andreas Gruenbacher
gfs2: Silence possible null pointer dereference warning

In gfs2_rbm_find, rs is always NULL when minext is NULL, so
gfs2_reservation_check_and_update will never be called on a NULL minext.
This isn't immediately obvious though, so also check for a NULL minext
for better code readability.

Reported-by: kernel test robot 
Signed-off-by: Andreas Gruenbacher 
---
 fs/gfs2/rgrp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 89c37a845e64..2dab313442a7 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1783,7 +1783,7 @@ static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, 
u32 *minext,
goto next_bitmap;
}
rbm->offset = offset;
-   if (!rs)
+   if (!rs || !minext)
return 0;
 
ret = gfs2_reservation_check_and_update(rbm, rs, *minext,
-- 
2.27.0



Re: [PATCH net-next v8 1/2] net: Add a WWAN subsystem

2021-04-02 Thread kernel test robot
Hi Loic,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Loic-Poulain/net-Add-a-WWAN-subsystem/20210402-220002
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 
bd78980be1a68d14524c51c4b4170782fada622b
config: i386-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

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


cocci warnings: (new ones prefixed by >>)
>> drivers/net/wwan/wwan_core.c:208:9-16: WARNING: ERR_CAST can be used with 
>> wwandev

Please review and possibly fold the followup patch.

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


.config.gz
Description: application/gzip


[PATCH] net: fix err_cast.cocci warnings

2021-04-02 Thread kernel test robot
From: kernel test robot 

drivers/net/wwan/wwan_core.c:208:9-16: WARNING: ERR_CAST can be used with 
wwandev


 Use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(...))

Generated by: scripts/coccinelle/api/err_cast.cocci

CC: Loic Poulain 
Reported-by: kernel test robot 
Signed-off-by: kernel test robot 
---

url:
https://github.com/0day-ci/linux/commits/Loic-Poulain/net-Add-a-WWAN-subsystem/20210402-220002
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 
bd78980be1a68d14524c51c4b4170782fada622b

 wwan_core.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/net/wwan/wwan_core.c
+++ b/drivers/net/wwan/wwan_core.c
@@ -205,7 +205,7 @@ struct wwan_port *wwan_create_port(struc
 */
wwandev = wwan_create_dev(parent);
if (IS_ERR(wwandev))
-   return ERR_PTR(PTR_ERR(wwandev));
+   return ERR_CAST(wwandev);
 
/* A port is exposed as character device, get a minor */
minor = ida_alloc_range(, 0, WWAN_MAX_MINORS - 1, GFP_KERNEL);


Re: [PATCH] lib/string: Introduce sysfs_streqcase

2021-04-02 Thread kernel test robot
Hi Gioh,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on linus/master next-20210401]
[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/Gioh-Kim/lib-string-Introduce-sysfs_streqcase/20210402-174251
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
5e46d1b78a03d52306f21f77a4e4a144b6d31486
config: mips-randconfig-r006-20210402 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 
b23a314146956dd29b719ab537608ced736fc036)
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
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# 
https://github.com/0day-ci/linux/commit/b18d0dc7264473a4023926c510a67adfd7eaf119
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Gioh-Kim/lib-string-Introduce-sysfs_streqcase/20210402-174251
git checkout b18d0dc7264473a4023926c510a67adfd7eaf119
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips 

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

All warnings (new ones prefixed by >>):

>> lib/string.c:723:6: warning: no previous prototype for function 
>> 'sysfs_streqcase' [-Wmissing-prototypes]
   bool sysfs_streqcase(const char *s1, const char *s2)
^
   lib/string.c:723:1: note: declare 'static' if the function is not intended 
to be used outside of this translation unit
   bool sysfs_streqcase(const char *s1, const char *s2)
   ^
   static 
   1 warning generated.


vim +/sysfs_streqcase +723 lib/string.c

   716  
   717  /**
   718   * sysfs_streqcase - same to sysfs_streq and case insensitive
   719   * @s1: one string
   720   * @s2: another string
   721   *
   722   */
 > 723  bool sysfs_streqcase(const char *s1, const char *s2)
   724  {
   725  while (*s1 && tolower(*s1) == tolower(*s2)) {
   726  s1++;
   727  s2++;
   728  }
   729  
   730  if (*s1 == *s2)
   731  return true;
   732  if (!*s1 && *s2 == '\n' && !s2[1])
   733  return true;
   734  if (*s1 == '\n' && !s1[1] && !*s2)
   735  return true;
   736  return false;
   737  }
   738  EXPORT_SYMBOL(sysfs_streqcase);
   739  

---
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] kunit: tool: make --kunitconfig accept dirs, add lib/kunit fragment

2021-04-02 Thread Shuah Khan

On 4/2/21 3:32 AM, Brendan Higgins wrote:

TL;DR
$ ./tools/testing/kunit/kunit.py run --kunitconfig=lib/kunit

Per suggestion from Ted [1], we can reduce the amount of typing by
assuming a convention that these files are named '.kunitconfig'.

In the case of [1], we now have
$ ./tools/testing/kunit/kunit.py run --kunitconfig=fs/ext4

Also add in such a fragment for kunit itself so we can give that as an
example more close to home (and thus less likely to be accidentally
broken).

[1] https://lore.kernel.org/linux-ext4/ycnf4yp1db97z...@mit.edu/

Signed-off-by: Daniel Latypov 


Reviewed-by: Brendan Higgins 



Should this be captured in  documentation. Especially since this
is file is .* file.

Do you want to include doc in this patch? Might be better that way.

thanks,
-- Shuah


Re: [PATCH v1 0/2] Add imx8m power domain driver

2021-04-02 Thread Abel Vesa
On 21-04-02 19:48:41, Adrien Grassein wrote:
> Hi,
> 
> Le ven. 2 avr. 2021 à 19:42, Abel Vesa  a écrit :
> >
> > On 21-04-02 18:45:04, Adrien Grassein wrote:
> > > Hi,
> > >
> > > this patch et aims to add the support of the i.MX 8 Power Domain driver.
> > > Some devices (like usbotg2) can't work without this patch as their
> > > attached power domain are down.
> > >
> > > The original drivr was taken from le imx kernel and aapted to fit with
> > > the actual mainline (minor fixes).
> > >
> > > Thanks,
> > >
> >
> > Big NACK for the whole series.
> >
> > This approach has already been rejected upstream.
> 
> So what is the correct approach?
> At this point otg2 node of imx8mm is not working at all (and blocks the whole
> boot of the kernel)
> 

Have a look at this thread:

https://lkml.org/lkml/2020/4/27/706

> >
> > Plus, you changed the original author, this work was originally done by 
> > Jacky Bai.
> 
> I have not changed this, the original author is not mentioned on the
> original patch.

Here is the original commit:

https://github.com/Freescale/linux-fslc/commit/7ebcf5ccf423afe4ccd9c53ef204018b0b653ce0


> 
> >
> > > Adrien Grassein (2):
> > >   dt-bindings: power: Add documentation for imx8m power domain driver
> > >   soc: imx: add Power Domain driver for i.MX8M(M|N|P)
> > >
> > >  .../bindings/power/fsl,imx-power-domain.yaml  |  89 +++
> > >  MAINTAINERS   |  10 +
> > >  drivers/soc/imx/Kconfig   |   7 +
> > >  drivers/soc/imx/Makefile  |   1 +
> > >  drivers/soc/imx/imx8m_pm_domains.c| 233 ++
> > >  include/dt-bindings/power/imx8mm-power.h  |  21 ++
> > >  include/dt-bindings/power/imx8mn-power.h  |  15 ++
> > >  include/dt-bindings/power/imx8mp-power.h  |  28 +++
> > >  include/soc/imx/imx_sip.h |  12 +
> > >  9 files changed, 416 insertions(+)
> > >  create mode 100644 
> > > Documentation/devicetree/bindings/power/fsl,imx-power-domain.yaml
> > >  create mode 100644 drivers/soc/imx/imx8m_pm_domains.c
> > >  create mode 100644 include/dt-bindings/power/imx8mm-power.h
> > >  create mode 100644 include/dt-bindings/power/imx8mn-power.h
> > >  create mode 100644 include/dt-bindings/power/imx8mp-power.h
> > >  create mode 100644 include/soc/imx/imx_sip.h
> > >
> > > --
> > > 2.25.1
> > >
> 
> Thanks,


Re: [PATCH v6 3/4] x86/vmemmap: Handle unpopulated sub-pmd ranges

2021-04-02 Thread Oscar Salvador
On Tue, Mar 30, 2021 at 03:29:50AM +0100, Matthew Wilcox wrote:
> I can reproduce this with next-20210329.
> 
> .config attached.

Hi Matthew,

Thanks for the report. I tried to reproduce this with the attached
config on next-20210401 and I had no luck.


You still see it on that one?

Thanks

-- 
Oscar Salvador
SUSE L3


[PATCH v1] Bluetooth: Return whether a connection is outbound

2021-04-02 Thread Yu Liu
When an MGMT_EV_DEVICE_CONNECTED event is reported back to the user
space we will set the flags to tell if the established connection is
outbound or not. This is useful for the user space to log better metrics
and error messages.

Reviewed-by: Miao-chen Chou 
Reviewed-by: Alain Michaud 
Signed-off-by: Yu Liu 
---

Changes in v1:
- Initial change

 include/net/bluetooth/mgmt.h | 2 ++
 net/bluetooth/mgmt.c | 5 +
 2 files changed, 7 insertions(+)

diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index a7cffb069565..7cc724386b00 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -885,6 +885,8 @@ struct mgmt_ev_new_long_term_key {
struct mgmt_ltk_info key;
 } __packed;
 
+#define MGMT_DEV_CONN_INITIATED_CONNECTION 0x08
+
 #define MGMT_EV_DEVICE_CONNECTED   0x000B
 struct mgmt_ev_device_connected {
struct mgmt_addr_info addr;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 09e099c419f2..77213e67e8e4 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -8774,6 +8774,11 @@ void mgmt_device_connected(struct hci_dev *hdev, struct 
hci_conn *conn,
bacpy(>addr.bdaddr, >dst);
ev->addr.type = link_to_bdaddr(conn->type, conn->dst_type);
 
+   if (conn->out)
+   flags |= MGMT_DEV_CONN_INITIATED_CONNECTION;
+   else
+   flags &= ~MGMT_DEV_CONN_INITIATED_CONNECTION;
+
ev->flags = __cpu_to_le32(flags);
 
/* We must ensure that the EIR Data fields are ordered and
-- 
2.31.0.208.g409f899ff0-goog



Re: [PATCH v2] psi: allow unprivileged users with CAP_SYS_RESOURCE to write psi files

2021-04-02 Thread Johannes Weiner
On Thu, Apr 01, 2021 at 10:58:33PM -0400, Josh Hunt wrote:
> Currently only root can write files under /proc/pressure. Relax this to
> allow tasks running as unprivileged users with CAP_SYS_RESOURCE to be
> able to write to these files.
> 
> Signed-off-by: Josh Hunt 
> Acked-by: Johannes Weiner 

v2 looks good to me. Thanks


Re: [PATCH v4 1/2] kunit: support failure from dynamic analysis tools

2021-04-02 Thread Shuah Khan

On 4/2/21 2:55 AM, Brendan Higgins wrote:

On Thu, Mar 11, 2021 at 7:23 AM Daniel Latypov  wrote:


From: Uriel Guajardo 

Add a kunit_fail_current_test() function to fail the currently running
test, if any, with an error message.

This is largely intended for dynamic analysis tools like UBSAN and for
fakes.
E.g. say I had a fake ops struct for testing and I wanted my `free`
function to complain if it was called with an invalid argument, or
caught a double-free. Most return void and have no normal means of
signalling failure (e.g. super_operations, iommu_ops, etc.).

Key points:
* Always update current->kunit_test so anyone can use it.
   * commit 83c4e7a0363b ("KUnit: KASAN Integration") only updated it for
   CONFIG_KASAN=y

* Create a new header  so non-test code doesn't have
to include all of  (e.g. lib/ubsan.c)

* Forward the file and line number to make it easier to track down
failures

* Declare the helper function for nice __printf() warnings about mismatched
format strings even when KUnit is not enabled.

Example output from kunit_fail_current_test("message"):
[15:19:34] [FAILED] example_simple_test
[15:19:34] # example_simple_test: initializing
[15:19:34] # example_simple_test: lib/kunit/kunit-example-test.c:24: message
[15:19:34] not ok 1 - example_simple_test

Co-developed-by: Daniel Latypov 
Signed-off-by: Daniel Latypov 
Signed-off-by: Uriel Guajardo 
Reviewed-by: Alan Maguire 


Reviewed-by: Brendan Higgins 



Please run checkpatch on your patches in the future. I am seeing
a few checkpatch readability type improvements that can be made.

Please make changes and send v2 with Brendan's Reviewed-by.

thanks,
-- Shuah


Re: [PATCH] net: initialize local variables in net/ipv6/mcast.c and net/ipv4/igmp.c

2021-04-02 Thread Eric Dumazet



On 4/2/21 7:36 PM, Phillip Potter wrote:
> Use memset to initialize two local buffers in net/ipv6/mcast.c,
> and another in net/ipv4/igmp.c. Fixes a KMSAN found uninit-value
> bug reported by syzbot at:
> https://syzkaller.appspot.com/bug?id=0766d38c656abeace60621896d705743aeefed51


According to this link, the bug no longer triggers.

Please explain why you think it is still there.

> 
> Reported-by: syzbot+001516d86dbe88862...@syzkaller.appspotmail.com
> Signed-off-by: Phillip Potter 
> ---
>  net/ipv4/igmp.c  | 2 ++
>  net/ipv6/mcast.c | 4 
>  2 files changed, 6 insertions(+)
> 
> diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
> index 7b272bbed2b4..bc8e358a9a2a 100644
> --- a/net/ipv4/igmp.c
> +++ b/net/ipv4/igmp.c
> @@ -1131,6 +1131,8 @@ static void ip_mc_filter_add(struct in_device *in_dev, 
> __be32 addr)
>   char buf[MAX_ADDR_LEN];
>   struct net_device *dev = in_dev->dev;
>  
> + memset(buf, 0, sizeof(buf));
> +
>   /* Checking for IFF_MULTICAST here is WRONG-WRONG-WRONG.
>  We will get multicast token leakage, when IFF_MULTICAST
>  is changed. This check should be done in ndo_set_rx_mode
> diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
> index 6c8604390266..ad90dc28f318 100644
> --- a/net/ipv6/mcast.c
> +++ b/net/ipv6/mcast.c
> @@ -658,6 +658,8 @@ static void igmp6_group_added(struct ifmcaddr6 *mc)
>   struct net_device *dev = mc->idev->dev;
>   char buf[MAX_ADDR_LEN];
>  
> + memset(buf, 0, sizeof(buf));
> +
>   if (IPV6_ADDR_MC_SCOPE(>mca_addr) <
>   IPV6_ADDR_SCOPE_LINKLOCAL)
>   return;
> @@ -694,6 +696,8 @@ static void igmp6_group_dropped(struct ifmcaddr6 *mc)
>   struct net_device *dev = mc->idev->dev;
>   char buf[MAX_ADDR_LEN];
>  
> + memset(buf, 0, sizeof(buf));
> +
>   if (IPV6_ADDR_MC_SCOPE(>mca_addr) <
>   IPV6_ADDR_SCOPE_LINKLOCAL)
>   return;
> 


[PATCH v2 1/2] iio: trigger: Replace explicit casting and wrong specifier with proper one

2021-04-02 Thread Andy Shevchenko
By unknown reason device name is set with an index casted from int
to unsigned long while at the same time with "%ld" specifier. Both parts
seems wrong to me, thus replace replace explicit casting and wrong specifier
with proper one, i.e. "%d".

Signed-off-by: Andy Shevchenko 
---
v2: used %d which is really correct one
 drivers/iio/industrialio-trigger.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iio/industrialio-trigger.c 
b/drivers/iio/industrialio-trigger.c
index 32ac1bec25e3..78e30f0f915c 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -75,8 +75,7 @@ int __iio_trigger_register(struct iio_trigger *trig_info,
return trig_info->id;
 
/* Set the name used for the sysfs directory etc */
-   dev_set_name(_info->dev, "trigger%ld",
-(unsigned long) trig_info->id);
+   dev_set_name(_info->dev, "trigger%d", trig_info->id);
 
ret = device_add(_info->dev);
if (ret)
-- 
2.30.2



[PATCH v2 2/2] iio: trigger: Fix strange (ladder-type) indentation

2021-04-02 Thread Andy Shevchenko
In some cases indentation looks a bit weird with starting from = sign
and being in a ladder-type style. Unify it across the module.

While at it, add blank line after definition block where it needed,

Signed-off-by: Andy Shevchenko 
---
v2: fixed typo in the commit message (tupe->type)
 drivers/iio/industrialio-trigger.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/industrialio-trigger.c 
b/drivers/iio/industrialio-trigger.c
index 78e30f0f915c..ec72ff04b38d 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -211,6 +211,7 @@ EXPORT_SYMBOL(iio_trigger_notify_done);
 static int iio_trigger_get_irq(struct iio_trigger *trig)
 {
int ret;
+
mutex_lock(>pool_lock);
ret = bitmap_find_free_region(trig->pool,
  CONFIG_IIO_CONSUMERS_PER_TRIGGER,
@@ -239,9 +240,9 @@ static void iio_trigger_put_irq(struct iio_trigger *trig, 
int irq)
 int iio_trigger_attach_poll_func(struct iio_trigger *trig,
 struct iio_poll_func *pf)
 {
+   bool notinuse =
+   bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
int ret = 0;
-   bool notinuse
-   = bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
 
/* Prevent the module from being removed whilst attached to a trigger */
__module_get(pf->indio_dev->driver_module);
@@ -290,11 +291,10 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig,
 int iio_trigger_detach_poll_func(struct iio_trigger *trig,
 struct iio_poll_func *pf)
 {
+   bool no_other_users =
+   bitmap_weight(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER) == 
1;
int ret = 0;
-   bool no_other_users
-   = (bitmap_weight(trig->pool,
-CONFIG_IIO_CONSUMERS_PER_TRIGGER)
-  == 1);
+
if (trig->ops && trig->ops->set_trigger_state && no_other_users) {
ret = trig->ops->set_trigger_state(trig, false);
if (ret)
@@ -312,6 +312,7 @@ int iio_trigger_detach_poll_func(struct iio_trigger *trig,
 irqreturn_t iio_pollfunc_store_time(int irq, void *p)
 {
struct iio_poll_func *pf = p;
+
pf->timestamp = iio_get_time_ns(pf->indio_dev);
return IRQ_WAKE_THREAD;
 }
@@ -498,18 +499,16 @@ static const struct device_type iio_trig_type = {
 static void iio_trig_subirqmask(struct irq_data *d)
 {
struct irq_chip *chip = irq_data_get_irq_chip(d);
-   struct iio_trigger *trig
-   = container_of(chip,
-  struct iio_trigger, subirq_chip);
+   struct iio_trigger *trig = container_of(chip, struct iio_trigger, 
subirq_chip);
+
trig->subirqs[d->irq - trig->subirq_base].enabled = false;
 }
 
 static void iio_trig_subirqunmask(struct irq_data *d)
 {
struct irq_chip *chip = irq_data_get_irq_chip(d);
-   struct iio_trigger *trig
-   = container_of(chip,
-  struct iio_trigger, subirq_chip);
+   struct iio_trigger *trig = container_of(chip, struct iio_trigger, 
subirq_chip);
+
trig->subirqs[d->irq - trig->subirq_base].enabled = true;
 }
 
@@ -695,7 +694,7 @@ EXPORT_SYMBOL(iio_trigger_using_own);
  * device, -EINVAL otherwise.
  */
 int iio_trigger_validate_own_device(struct iio_trigger *trig,
-   struct iio_dev *indio_dev)
+   struct iio_dev *indio_dev)
 {
if (indio_dev->dev.parent != trig->dev.parent)
return -EINVAL;
-- 
2.30.2



Re: [PATCH v1 0/2] Add imx8m power domain driver

2021-04-02 Thread Adrien Grassein
Hi,

Le ven. 2 avr. 2021 à 19:42, Abel Vesa  a écrit :
>
> On 21-04-02 18:45:04, Adrien Grassein wrote:
> > Hi,
> >
> > this patch et aims to add the support of the i.MX 8 Power Domain driver.
> > Some devices (like usbotg2) can't work without this patch as their
> > attached power domain are down.
> >
> > The original drivr was taken from le imx kernel and aapted to fit with
> > the actual mainline (minor fixes).
> >
> > Thanks,
> >
>
> Big NACK for the whole series.
>
> This approach has already been rejected upstream.

So what is the correct approach?
At this point otg2 node of imx8mm is not working at all (and blocks the whole
boot of the kernel)

>
> Plus, you changed the original author, this work was originally done by Jacky 
> Bai.

I have not changed this, the original author is not mentioned on the
original patch.
(Taken from https://github.com/Freescale/linux-fslc branch 5.4-2.2.x-imx)

>
> > Adrien Grassein (2):
> >   dt-bindings: power: Add documentation for imx8m power domain driver
> >   soc: imx: add Power Domain driver for i.MX8M(M|N|P)
> >
> >  .../bindings/power/fsl,imx-power-domain.yaml  |  89 +++
> >  MAINTAINERS   |  10 +
> >  drivers/soc/imx/Kconfig   |   7 +
> >  drivers/soc/imx/Makefile  |   1 +
> >  drivers/soc/imx/imx8m_pm_domains.c| 233 ++
> >  include/dt-bindings/power/imx8mm-power.h  |  21 ++
> >  include/dt-bindings/power/imx8mn-power.h  |  15 ++
> >  include/dt-bindings/power/imx8mp-power.h  |  28 +++
> >  include/soc/imx/imx_sip.h |  12 +
> >  9 files changed, 416 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/power/fsl,imx-power-domain.yaml
> >  create mode 100644 drivers/soc/imx/imx8m_pm_domains.c
> >  create mode 100644 include/dt-bindings/power/imx8mm-power.h
> >  create mode 100644 include/dt-bindings/power/imx8mn-power.h
> >  create mode 100644 include/dt-bindings/power/imx8mp-power.h
> >  create mode 100644 include/soc/imx/imx_sip.h
> >
> > --
> > 2.25.1
> >

Thanks,


Re: [PATCH] kunit: make KUNIT_EXPECT_STREQ() quote values, don't print literals

2021-04-02 Thread Shuah Khan

On 4/2/21 3:35 AM, Brendan Higgins wrote:

On Fri, Feb 5, 2021 at 2:18 PM Daniel Latypov  wrote:


Before:

  Expected str == "world", but
  str == hello
  "world" == world


After:

  Expected str == "world", but
  str == "hello"



Note: like the literal ellision for integers, this doesn't handle the
case of
   KUNIT_EXPECT_STREQ(test, "hello", "world")
since we don't expect it to realistically happen in checked in tests.
(If you really wanted a test to fail, KUNIT_FAIL("msg") exists)

In that case, you'd get:

  Expected "hello" == "world", but



Signed-off-by: Daniel Latypov 


Reviewed-by: Brendan Higgins 



Hi Daniel,

Please run checkpatch on your patches in the future. I am seeing
a few checkpatch readability type improvements that can be made.

Please make changes and send v2 with Brendan's Reviewed-by.

thanks,
-- Shuah


Re: [PATCH v1 1/2] iio: trigger: Replace explicit casting and wrong specifier with proper one

2021-04-02 Thread Andy Shevchenko
On Fri, Apr 2, 2021 at 4:25 PM Andy Shevchenko
 wrote:
> On Friday, April 2, 2021, Jonathan Cameron  wrote:
>> On Thu,  1 Apr 2021 17:54:56 +0300
>> Andy Shevchenko  wrote:
>>
>> > By unknown reason device name is set with an index casted from int
>> > to unsigned long while at the same time with "%ld" specifier. Both parts
>> > seems wrong to me, thus replace replace explicit casting and wrong 
>> > specifier
>> > with proper one, i.e. "%u".
>> I'm not going to pretend to know what planet I was on when I wrote this :)
>
>
> Actually “%d” is even more correct (aligned with the type), but either will 
> work.

I have noticed a typo in the commit message of the other patch.
I'll send a v2 altogether.

>> Series applied to the togreg branch of iio.git and pushed out as testing
>> for the autobuilders to poke at.


-- 
With Best Regards,
Andy Shevchenko


[PATCH v2 10/10] ipmi_si: Join string literals back

2021-04-02 Thread Andy Shevchenko
For easy grepping on debug purposes join string literals back in
the messages.

No functional change.

Signed-off-by: Andy Shevchenko 
---
 drivers/char/ipmi/ipmi_msghandler.c  |  3 +-
 drivers/char/ipmi/ipmi_si_hardcode.c | 50 +---
 drivers/char/ipmi/ipmi_si_hotmod.c   |  5 ++-
 drivers/char/ipmi/ipmi_si_intf.c | 25 +-
 drivers/char/ipmi/ipmi_si_pci.c  |  4 +--
 drivers/char/ipmi/ipmi_si_platform.c | 17 +-
 6 files changed, 38 insertions(+), 66 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_msghandler.c 
b/drivers/char/ipmi/ipmi_msghandler.c
index 367616a408b6..8a0e97b33cae 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -5209,7 +5209,6 @@ module_exit(cleanup_ipmi);
 module_init(ipmi_init_msghandler_mod);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Corey Minyard ");
-MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI"
-  " interface.");
+MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI 
interface.");
 MODULE_VERSION(IPMI_DRIVER_VERSION);
 MODULE_SOFTDEP("post: ipmi_devintf");
diff --git a/drivers/char/ipmi/ipmi_si_hardcode.c 
b/drivers/char/ipmi/ipmi_si_hardcode.c
index bbcf7483d569..ed5e91b1e040 100644
--- a/drivers/char/ipmi/ipmi_si_hardcode.c
+++ b/drivers/char/ipmi/ipmi_si_hardcode.c
@@ -32,47 +32,29 @@ static int slave_addrs[SI_MAX_PARMS] __initdata;
 static unsigned int num_slave_addrs __initdata;
 
 module_param_string(type, si_type_str, MAX_SI_TYPE_STR, 0);
-MODULE_PARM_DESC(type, "Defines the type of each interface, each"
-" interface separated by commas.  The types are 'kcs',"
-" 'smic', and 'bt'.  For example si_type=kcs,bt will set"
-" the first interface to kcs and the second to bt");
+MODULE_PARM_DESC(type,
+"Defines the type of each interface, each interface separated 
by commas.  The types are 'kcs', 'smic', and 'bt'.  For example si_type=kcs,bt 
will set the first interface to kcs and the second to bt");
 module_param_hw_array(addrs, ulong, iomem, _addrs, 0);
-MODULE_PARM_DESC(addrs, "Sets the memory address of each interface, the"
-" addresses separated by commas.  Only use if an interface"
-" is in memory.  Otherwise, set it to zero or leave"
-" it blank.");
+MODULE_PARM_DESC(addrs,
+"Sets the memory address of each interface, the addresses 
separated by commas.  Only use if an interface is in memory.  Otherwise, set it 
to zero or leave it blank.");
 module_param_hw_array(ports, uint, ioport, _ports, 0);
-MODULE_PARM_DESC(ports, "Sets the port address of each interface, the"
-" addresses separated by commas.  Only use if an interface"
-" is a port.  Otherwise, set it to zero or leave"
-" it blank.");
+MODULE_PARM_DESC(ports,
+"Sets the port address of each interface, the addresses 
separated by commas.  Only use if an interface is a port.  Otherwise, set it to 
zero or leave it blank.");
 module_param_hw_array(irqs, int, irq, _irqs, 0);
-MODULE_PARM_DESC(irqs, "Sets the interrupt of each interface, the"
-" addresses separated by commas.  Only use if an interface"
-" has an interrupt.  Otherwise, set it to zero or leave"
-" it blank.");
+MODULE_PARM_DESC(irqs,
+"Sets the interrupt of each interface, the addresses separated 
by commas.  Only use if an interface has an interrupt.  Otherwise, set it to 
zero or leave it blank.");
 module_param_hw_array(regspacings, int, other, _regspacings, 0);
-MODULE_PARM_DESC(regspacings, "The number of bytes between the start address"
-" and each successive register used by the interface.  For"
-" instance, if the start address is 0xca2 and the spacing"
-" is 2, then the second address is at 0xca4.  Defaults"
-" to 1.");
+MODULE_PARM_DESC(regspacings,
+"The number of bytes between the start address and each 
successive register used by the interface.  For instance, if the start address 
is 0xca2 and the spacing is 2, then the second address is at 0xca4.  Defaults 
to 1.");
 module_param_hw_array(regsizes, int, other, _regsizes, 0);
-MODULE_PARM_DESC(regsizes, "The size of the specific IPMI register in bytes."
-" This should generally be 1, 2, 4, or 8 for an 8-bit,"
-" 16-bit, 32-bit, or 64-bit register.  Use this if you"
-" the 8-bit IPMI register has to be read from a larger"
-" register.");
+MODULE_PARM_DESC(regsizes,
+"The size of the specific IPMI register in bytes. This should 
generally be 1, 2, 4, or 8 for an 8-bit, 16-bit, 32-bit, or 64-bit register.  
Use this if you the 8-bit IPMI register has to be read from a larger 
register.");
 module_param_hw_array(regshifts, int, other, 

[PATCH v2 05/10] ipmi_si: Introduce ipmi_panic_event_str[] array

2021-04-02 Thread Andy Shevchenko
Instead of repeating twice the constant literals, introduce
ipmi_panic_event_str[] array. It allows to simplify the code
with help of match_string() API.

Signed-off-by: Andy Shevchenko 
---
 drivers/char/ipmi/ipmi_msghandler.c | 51 +++--
 1 file changed, 19 insertions(+), 32 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_msghandler.c 
b/drivers/char/ipmi/ipmi_msghandler.c
index f19f0f967e28..367616a408b6 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -49,11 +49,17 @@ static int handle_one_recv_msg(struct ipmi_smi *intf,
 static bool initialized;
 static bool drvregistered;
 
+/* Numbers in this enumerator should be mapped to ipmi_panic_event_str */
 enum ipmi_panic_event_op {
IPMI_SEND_PANIC_EVENT_NONE,
IPMI_SEND_PANIC_EVENT,
-   IPMI_SEND_PANIC_EVENT_STRING
+   IPMI_SEND_PANIC_EVENT_STRING,
+   IPMI_SEND_PANIC_EVENT_MAX
 };
+
+/* Indices in this array should be mapped to enum ipmi_panic_event_op */
+static const char *const ipmi_panic_event_str[] = { "none", "event", "string", 
NULL };
+
 #ifdef CONFIG_IPMI_PANIC_STRING
 #define IPMI_PANIC_DEFAULT IPMI_SEND_PANIC_EVENT_STRING
 #elif defined(CONFIG_IPMI_PANIC_EVENT)
@@ -68,46 +74,27 @@ static int panic_op_write_handler(const char *val,
  const struct kernel_param *kp)
 {
char valcp[16];
-   char *s;
-
-   strncpy(valcp, val, 15);
-   valcp[15] = '\0';
+   int e;
 
-   s = strstrip(valcp);
-
-   if (strcmp(s, "none") == 0)
-   ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT_NONE;
-   else if (strcmp(s, "event") == 0)
-   ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT;
-   else if (strcmp(s, "string") == 0)
-   ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT_STRING;
-   else
-   return -EINVAL;
+   strscpy(valcp, val, sizeof(valcp));
+   e = match_string(ipmi_panic_event_str, -1, strstrip(valcp));
+   if (e < 0)
+   return e;
 
+   ipmi_send_panic_event = e;
return 0;
 }
 
 static int panic_op_read_handler(char *buffer, const struct kernel_param *kp)
 {
-   switch (ipmi_send_panic_event) {
-   case IPMI_SEND_PANIC_EVENT_NONE:
-   strcpy(buffer, "none\n");
-   break;
-
-   case IPMI_SEND_PANIC_EVENT:
-   strcpy(buffer, "event\n");
-   break;
-
-   case IPMI_SEND_PANIC_EVENT_STRING:
-   strcpy(buffer, "string\n");
-   break;
+   const char *event_str;
 
-   default:
-   strcpy(buffer, "???\n");
-   break;
-   }
+   if (ipmi_send_panic_event >= IPMI_SEND_PANIC_EVENT_MAX)
+   event_str = "???";
+   else
+   event_str = ipmi_panic_event_str[ipmi_send_panic_event];
 
-   return strlen(buffer);
+   return sprintf(buffer, "%s\n", event_str);
 }
 
 static const struct kernel_param_ops panic_op_ops = {
-- 
2.30.2



[PATCH v2 07/10] ipmi_si: Get rid of ->addr_source_cleanup()

2021-04-02 Thread Andy Shevchenko
The ->addr_source_cleanup() callback is solely used by PCI driver
and only for one purpose, i.e. to disable device. Get rid of
->addr_source_cleanup() by switching to PCI managed API.

Signed-off-by: Andy Shevchenko 
---
 drivers/char/ipmi/ipmi_si.h  |  2 --
 drivers/char/ipmi/ipmi_si_intf.c |  4 
 drivers/char/ipmi/ipmi_si_pci.c  | 18 ++
 3 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_si.h b/drivers/char/ipmi/ipmi_si.h
index 9492c53eba86..0a4c69539f24 100644
--- a/drivers/char/ipmi/ipmi_si.h
+++ b/drivers/char/ipmi/ipmi_si.h
@@ -52,8 +52,6 @@ struct si_sm_io {
enum ipmi_addr_space addr_space;
unsigned long addr_data;
enum ipmi_addr_src addr_source; /* ACPI, PCI, SMBIOS, hardcode, etc. */
-   void (*addr_source_cleanup)(struct si_sm_io *io);
-   void *addr_source_data;
union ipmi_smi_info_union addr_info;
 
int (*io_setup)(struct si_sm_io *info);
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index d6ecf88636c4..5bf0ab61261f 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2206,10 +2206,6 @@ static void shutdown_smi(void *send_info)
if (smi_info->handlers)
smi_info->handlers->cleanup(smi_info->si_sm);
 
-   if (smi_info->io.addr_source_cleanup) {
-   smi_info->io.addr_source_cleanup(_info->io);
-   smi_info->io.addr_source_cleanup = NULL;
-   }
if (smi_info->io.io_cleanup) {
smi_info->io.io_cleanup(_info->io);
smi_info->io.io_cleanup = NULL;
diff --git a/drivers/char/ipmi/ipmi_si_pci.c b/drivers/char/ipmi/ipmi_si_pci.c
index 95bbcfba5408..0bc7efb6902c 100644
--- a/drivers/char/ipmi/ipmi_si_pci.c
+++ b/drivers/char/ipmi/ipmi_si_pci.c
@@ -21,13 +21,6 @@ MODULE_PARM_DESC(trypci, "Setting this to zero will disable 
the"
 
 #define PCI_DEVICE_ID_HP_MMC 0x121A
 
-static void ipmi_pci_cleanup(struct si_sm_io *io)
-{
-   struct pci_dev *pdev = io->addr_source_data;
-
-   pci_disable_device(pdev);
-}
-
 static int ipmi_pci_probe_regspacing(struct si_sm_io *io)
 {
if (io->si_type == SI_KCS) {
@@ -97,15 +90,12 @@ static int ipmi_pci_probe(struct pci_dev *pdev,
return -ENOMEM;
}
 
-   rv = pci_enable_device(pdev);
+   rv = pcim_enable_device(pdev);
if (rv) {
dev_err(>dev, "couldn't enable PCI device\n");
return rv;
}
 
-   io.addr_source_cleanup = ipmi_pci_cleanup;
-   io.addr_source_data = pdev;
-
if (pci_resource_flags(pdev, 0) & IORESOURCE_IO) {
io.addr_space = IPMI_IO_ADDR_SPACE;
io.io_setup = ipmi_si_port_setup;
@@ -128,11 +118,7 @@ static int ipmi_pci_probe(struct pci_dev *pdev,
dev_info(>dev, "%pR regsize %d spacing %d irq %d\n",
 >resource[0], io.regsize, io.regspacing, io.irq);
 
-   rv = ipmi_si_add_smi();
-   if (rv)
-   pci_disable_device(pdev);
-
-   return rv;
+   return ipmi_si_add_smi();
 }
 
 static void ipmi_pci_remove(struct pci_dev *pdev)
-- 
2.30.2



[PATCH v2 06/10] ipmi_si: Reuse si_to_str[] array in ipmi_hardcode_init_one()

2021-04-02 Thread Andy Shevchenko
Instead of making the comparison one by one, reuse si_to_str[] array
in ipmi_hardcode_init_one() in conjunction with match_string() API.

Signed-off-by: Andy Shevchenko 
---
 drivers/char/ipmi/ipmi_si.h  |  6 +-
 drivers/char/ipmi/ipmi_si_hardcode.c | 23 +--
 drivers/char/ipmi/ipmi_si_intf.c |  3 ++-
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_si.h b/drivers/char/ipmi/ipmi_si.h
index bac0ff86e48e..9492c53eba86 100644
--- a/drivers/char/ipmi/ipmi_si.h
+++ b/drivers/char/ipmi/ipmi_si.h
@@ -18,10 +18,14 @@
 #define DEFAULT_REGSPACING 1
 #define DEFAULT_REGSIZE1
 
+/* Numbers in this enumerator should be mapped to si_to_str[] */
 enum si_type {
-   SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT
+   SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT, SI_TYPE_MAX
 };
 
+/* Array is defined in the ipmi_si_intf.c */
+extern const char *const si_to_str[];
+
 enum ipmi_addr_space {
IPMI_IO_ADDR_SPACE, IPMI_MEM_ADDR_SPACE
 };
diff --git a/drivers/char/ipmi/ipmi_si_hardcode.c 
b/drivers/char/ipmi/ipmi_si_hardcode.c
index f6ece7569504..bbcf7483d569 100644
--- a/drivers/char/ipmi/ipmi_si_hardcode.c
+++ b/drivers/char/ipmi/ipmi_si_hardcode.c
@@ -80,26 +80,21 @@ static void __init ipmi_hardcode_init_one(const char 
*si_type_str,
  enum ipmi_addr_space addr_space)
 {
struct ipmi_plat_data p;
+   int t;
 
memset(, 0, sizeof(p));
 
p.iftype = IPMI_PLAT_IF_SI;
-   if (!si_type_str || !*si_type_str || strcmp(si_type_str, "kcs") == 0) {
+   if (!si_type_str || !*si_type_str) {
p.type = SI_KCS;
-   } else if (strcmp(si_type_str, "smic") == 0) {
-   p.type = SI_SMIC;
-   } else if (strcmp(si_type_str, "bt") == 0) {
-   p.type = SI_BT;
-   } else if (strcmp(si_type_str, "invalid") == 0) {
-   /*
-* Allow a firmware-specified interface to be
-* disabled.
-*/
-   p.type = SI_TYPE_INVALID;
} else {
-   pr_warn("Interface type specified for interface %d, was 
invalid: %s\n",
-   i, si_type_str);
-   return;
+   t = match_string(si_to_str, -1, si_type_str);
+   if (t < 0) {
+   pr_warn("Interface type specified for interface %d, was 
invalid: %s\n",
+   i, si_type_str);
+   return;
+   }
+   p.type = t;
}
 
p.regsize = regsizes[i];
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index be41a473e3c2..d6ecf88636c4 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -70,7 +70,8 @@ enum si_intf_state {
 #define IPMI_BT_INTMASK_CLEAR_IRQ_BIT  2
 #define IPMI_BT_INTMASK_ENABLE_IRQ_BIT 1
 
-static const char * const si_to_str[] = { "invalid", "kcs", "smic", "bt" };
+/* 'invalid' to allow a firmware-specified interface to be disabled */
+const char *const si_to_str[] = { "invalid", "kcs", "smic", "bt", NULL };
 
 static bool initialized;
 
-- 
2.30.2



[PATCH v2 08/10] ipmi_si: Use strstrip() to remove surrounding spaces

2021-04-02 Thread Andy Shevchenko
Instead of home grown analogue, use strstrip() from the kernel library.

Signed-off-by: Andy Shevchenko 
---
 drivers/char/ipmi/ipmi_si_hotmod.c | 16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_si_hotmod.c 
b/drivers/char/ipmi/ipmi_si_hotmod.c
index 4fbb4e18bae2..087f5eb1ebc0 100644
--- a/drivers/char/ipmi/ipmi_si_hotmod.c
+++ b/drivers/char/ipmi/ipmi_si_hotmod.c
@@ -185,24 +185,16 @@ static atomic_t hotmod_nr;
 
 static int hotmod_handler(const char *val, const struct kernel_param *kp)
 {
-   char *str = kstrdup(val, GFP_KERNEL), *curr, *next;
int  rv;
struct ipmi_plat_data h;
-   unsigned int len;
-   int ival;
+   char *str, *curr, *next;
 
+   str = kstrdup(val, GFP_KERNEL);
if (!str)
return -ENOMEM;
 
/* Kill any trailing spaces, as we can get a "\n" from echo. */
-   len = strlen(str);
-   ival = len - 1;
-   while ((ival >= 0) && isspace(str[ival])) {
-   str[ival] = '\0';
-   ival--;
-   }
-
-   for (curr = str; curr; curr = next) {
+   for (curr = strstrip(str); curr; curr = next) {
enum hotmod_op op;
 
next = strchr(curr, ':');
@@ -235,7 +227,7 @@ static int hotmod_handler(const char *val, const struct 
kernel_param *kp)
put_device(dev);
}
}
-   rv = len;
+   rv = strlen(val);
 out:
kfree(str);
return rv;
-- 
2.30.2



[PATCH v2 09/10] ipmi_si: Drop redundant check before calling put_device()

2021-04-02 Thread Andy Shevchenko
put_device() is NULL aware, drop redundant check before calling it.

Signed-off-by: Andy Shevchenko 
---
 drivers/char/ipmi/ipmi_si_hotmod.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_si_hotmod.c 
b/drivers/char/ipmi/ipmi_si_hotmod.c
index 087f5eb1ebc0..a07ef37c0e3f 100644
--- a/drivers/char/ipmi/ipmi_si_hotmod.c
+++ b/drivers/char/ipmi/ipmi_si_hotmod.c
@@ -223,8 +223,7 @@ static int hotmod_handler(const char *val, const struct 
kernel_param *kp)
if (strcmp(pdev->name, "hotmod-ipmi-si") == 0)
platform_device_unregister(pdev);
}
-   if (dev)
-   put_device(dev);
+   put_device(dev);
}
}
rv = strlen(val);
-- 
2.30.2



[PATCH v2 01/10] ipmi_si: Switch to use platform_get_mem_or_io()

2021-04-02 Thread Andy Shevchenko
Switch to use new platform_get_mem_or_io() instead of home grown analogue.
Note, we also introduce ipmi_set_addr_data_and_space() helper here.

Signed-off-by: Andy Shevchenko 
---
 drivers/char/ipmi/ipmi_si_platform.c | 34 
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_si_platform.c 
b/drivers/char/ipmi/ipmi_si_platform.c
index 129b5713f187..8f2fefc015b2 100644
--- a/drivers/char/ipmi/ipmi_si_platform.c
+++ b/drivers/char/ipmi/ipmi_si_platform.c
@@ -100,32 +100,31 @@ static int acpi_gpe_irq_setup(struct si_sm_io *io)
 }
 #endif
 
+static void ipmi_set_addr_data_and_space(struct resource *r, struct si_sm_io 
*io)
+{
+   if (resource_type(r) == IORESOURCE_IO)
+   io->addr_space = IPMI_IO_ADDR_SPACE;
+   else
+   io->addr_space = IPMI_MEM_ADDR_SPACE;
+   io->addr_data = r->start;
+}
+
 static struct resource *
 ipmi_get_info_from_resources(struct platform_device *pdev,
 struct si_sm_io *io)
 {
struct resource *res, *res_second;
 
-   res = platform_get_resource(pdev, IORESOURCE_IO, 0);
-   if (res) {
-   io->addr_space = IPMI_IO_ADDR_SPACE;
-   } else {
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (res)
-   io->addr_space = IPMI_MEM_ADDR_SPACE;
-   }
+   res = platform_get_mem_or_io(pdev, 0);
if (!res) {
dev_err(>dev, "no I/O or memory address\n");
return NULL;
}
-   io->addr_data = res->start;
+   ipmi_set_addr_data_and_space(res, io);
 
io->regspacing = DEFAULT_REGSPACING;
-   res_second = platform_get_resource(pdev,
-  (io->addr_space == IPMI_IO_ADDR_SPACE) ?
-   IORESOURCE_IO : IORESOURCE_MEM,
-  1);
-   if (res_second) {
+   res_second = platform_get_mem_or_io(pdev, 1);
+   if (res_second && resource_type(res_second) == resource_type(res)) {
if (res_second->start > io->addr_data)
io->regspacing = res_second->start - io->addr_data;
}
@@ -275,12 +274,7 @@ static int of_ipmi_probe(struct platform_device *pdev)
io.addr_source  = SI_DEVICETREE;
io.irq_setup= ipmi_std_irq_setup;
 
-   if (resource.flags & IORESOURCE_IO)
-   io.addr_space = IPMI_IO_ADDR_SPACE;
-   else
-   io.addr_space = IPMI_MEM_ADDR_SPACE;
-
-   io.addr_data= resource.start;
+   ipmi_set_addr_data_and_space(, );
 
io.regsize  = regsize ? be32_to_cpup(regsize) : DEFAULT_REGSIZE;
io.regspacing   = regspacing ? be32_to_cpup(regspacing) : 
DEFAULT_REGSPACING;
-- 
2.30.2



[PATCH v2 00/10] ipmi_si: Set of clean ups

2021-04-02 Thread Andy Shevchenko
The series contains set of clean ups, main parts of which are:
 - use ne platform_get_mem_or_io() API
 - use match_string() API

Since v2:
- patch 3: rephrased commit message (Corey)
- patch 5: added a comment that array maps to enum (Corey)
- patch 5: added "ipmi" prefix to the name of the array
- patch 6: just exported array w/o moving to header (Corey)
- wrapped up cover letter

Andy Shevchenko (10):
  ipmi_si: Switch to use platform_get_mem_or_io()
  ipmi_si: Remove bogus err_free label
  ipmi_si: Utilize temporary variable to hold device pointer
  ipmi_si: Use proper ACPI macros to check error code for failures
  ipmi_si: Introduce ipmi_panic_event_str[] array
  ipmi_si: Reuse si_to_str[] array in ipmi_hardcode_init_one()
  ipmi_si: Get rid of ->addr_source_cleanup()
  ipmi_si: Use strstrip() to remove surrounding spaces
  ipmi_si: Drop redundant check before calling put_device()
  ipmi_si: Join string literals back

 drivers/char/ipmi/ipmi_msghandler.c  | 54 ++--
 drivers/char/ipmi/ipmi_si.h  |  8 ++-
 drivers/char/ipmi/ipmi_si_hardcode.c | 73 -
 drivers/char/ipmi/ipmi_si_hotmod.c   | 24 ++-
 drivers/char/ipmi/ipmi_si_intf.c | 32 --
 drivers/char/ipmi/ipmi_si_pci.c  | 22 ++-
 drivers/char/ipmi/ipmi_si_platform.c | 95 
 7 files changed, 112 insertions(+), 196 deletions(-)

-- 
2.30.2



[PATCH v2 02/10] ipmi_si: Remove bogus err_free label

2021-04-02 Thread Andy Shevchenko
There is no more 'free' in the error path, so drop the label and
return errors inline.

Signed-off-by: Andy Shevchenko 
---
 drivers/char/ipmi/ipmi_si_platform.c | 17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_si_platform.c 
b/drivers/char/ipmi/ipmi_si_platform.c
index 8f2fefc015b2..e5cd5006f0e5 100644
--- a/drivers/char/ipmi/ipmi_si_platform.c
+++ b/drivers/char/ipmi/ipmi_si_platform.c
@@ -316,7 +316,6 @@ static int acpi_ipmi_probe(struct platform_device *pdev)
acpi_status status;
unsigned long long tmp;
struct resource *res;
-   int rv = -EINVAL;
 
if (!si_tryacpi)
return -ENODEV;
@@ -336,7 +335,7 @@ static int acpi_ipmi_probe(struct platform_device *pdev)
if (ACPI_FAILURE(status)) {
dev_err(>dev,
"Could not find ACPI IPMI interface type\n");
-   goto err_free;
+   return -EINVAL;
}
 
switch (tmp) {
@@ -350,21 +349,18 @@ static int acpi_ipmi_probe(struct platform_device *pdev)
io.si_type = SI_BT;
break;
case 4: /* SSIF, just ignore */
-   rv = -ENODEV;
-   goto err_free;
+   return -ENODEV;
default:
dev_info(>dev, "unknown IPMI type %lld\n", tmp);
-   goto err_free;
+   return -EINVAL;
}
 
io.regsize = DEFAULT_REGSIZE;
io.regshift = 0;
 
res = ipmi_get_info_from_resources(pdev, );
-   if (!res) {
-   rv = -EINVAL;
-   goto err_free;
-   }
+   if (!res)
+   return -EINVAL;
 
/* If _GPE exists, use it; otherwise use standard interrupts */
status = acpi_evaluate_integer(handle, "_GPE", NULL, );
@@ -390,9 +386,6 @@ static int acpi_ipmi_probe(struct platform_device *pdev)
request_module("acpi_ipmi");
 
return ipmi_si_add_smi();
-
-err_free:
-   return rv;
 }
 
 static const struct acpi_device_id acpi_ipmi_match[] = {
-- 
2.30.2



[PATCH v2 03/10] ipmi_si: Utilize temporary variable to hold device pointer

2021-04-02 Thread Andy Shevchenko
Introduce a temporary variable to hold a device pointer.
It can be utilized in the ->probe() and save a bit of LOCs.

Signed-off-by: Andy Shevchenko 
---
 drivers/char/ipmi/ipmi_si_platform.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_si_platform.c 
b/drivers/char/ipmi/ipmi_si_platform.c
index e5cd5006f0e5..5f641d316ecb 100644
--- a/drivers/char/ipmi/ipmi_si_platform.c
+++ b/drivers/char/ipmi/ipmi_si_platform.c
@@ -311,6 +311,7 @@ static int find_slave_address(struct si_sm_io *io, int 
slave_addr)
 
 static int acpi_ipmi_probe(struct platform_device *pdev)
 {
+   struct device *dev = >dev;
struct si_sm_io io;
acpi_handle handle;
acpi_status status;
@@ -320,21 +321,20 @@ static int acpi_ipmi_probe(struct platform_device *pdev)
if (!si_tryacpi)
return -ENODEV;
 
-   handle = ACPI_HANDLE(>dev);
+   handle = ACPI_HANDLE(dev);
if (!handle)
return -ENODEV;
 
memset(, 0, sizeof(io));
io.addr_source = SI_ACPI;
-   dev_info(>dev, "probing via ACPI\n");
+   dev_info(dev, "probing via ACPI\n");
 
io.addr_info.acpi_info.acpi_handle = handle;
 
/* _IFT tells us the interface type: KCS, BT, etc */
status = acpi_evaluate_integer(handle, "_IFT", NULL, );
if (ACPI_FAILURE(status)) {
-   dev_err(>dev,
-   "Could not find ACPI IPMI interface type\n");
+   dev_err(dev, "Could not find ACPI IPMI interface type\n");
return -EINVAL;
}
 
@@ -351,10 +351,11 @@ static int acpi_ipmi_probe(struct platform_device *pdev)
case 4: /* SSIF, just ignore */
return -ENODEV;
default:
-   dev_info(>dev, "unknown IPMI type %lld\n", tmp);
+   dev_info(dev, "unknown IPMI type %lld\n", tmp);
return -EINVAL;
}
 
+   io.dev = dev;
io.regsize = DEFAULT_REGSIZE;
io.regshift = 0;
 
@@ -378,9 +379,7 @@ static int acpi_ipmi_probe(struct platform_device *pdev)
 
io.slave_addr = find_slave_address(, io.slave_addr);
 
-   io.dev = >dev;
-
-   dev_info(io.dev, "%pR regsize %d spacing %d irq %d\n",
+   dev_info(dev, "%pR regsize %d spacing %d irq %d\n",
 res, io.regsize, io.regspacing, io.irq);
 
request_module("acpi_ipmi");
-- 
2.30.2



[PATCH v2 04/10] ipmi_si: Use proper ACPI macros to check error code for failures

2021-04-02 Thread Andy Shevchenko
Instead of direct comparison, use proper ACPI macros to check error code
for failures.

While at it, drop unneeded 'else' keyword.

Signed-off-by: Andy Shevchenko 
---
 drivers/char/ipmi/ipmi_si_platform.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_si_platform.c 
b/drivers/char/ipmi/ipmi_si_platform.c
index 5f641d316ecb..b87bd9933724 100644
--- a/drivers/char/ipmi/ipmi_si_platform.c
+++ b/drivers/char/ipmi/ipmi_si_platform.c
@@ -85,18 +85,18 @@ static int acpi_gpe_irq_setup(struct si_sm_io *io)
  ACPI_GPE_LEVEL_TRIGGERED,
  _acpi_gpe,
  io);
-   if (status != AE_OK) {
+   if (ACPI_FAILURE(status)) {
dev_warn(io->dev,
 "Unable to claim ACPI GPE %d, running polled\n",
 io->irq);
io->irq = 0;
return -EINVAL;
-   } else {
-   io->irq_cleanup = acpi_gpe_irq_cleanup;
-   ipmi_irq_finish_setup(io);
-   dev_info(io->dev, "Using ACPI GPE %d\n", io->irq);
-   return 0;
}
+
+   io->irq_cleanup = acpi_gpe_irq_cleanup;
+   ipmi_irq_finish_setup(io);
+   dev_info(io->dev, "Using ACPI GPE %d\n", io->irq);
+   return 0;
 }
 #endif
 
-- 
2.30.2



[PATCH] iio: buffer: use sysfs_attr_init() on allocated attrs

2021-04-02 Thread Alexandru Ardelean
When dynamically allocating sysfs attributes, it's a good idea to call
sysfs_attr_init() on them to initialize lock_class_keys.
This change does that.

The lock_class_keys are set when the CONFIG_DEBUG_LOCK_ALLOC symbol is
enabled. Which is [likely] one reason why I did not see this during
development.

I also am not able to see this even with CONFIG_DEBUG_LOCK_ALLOC enabled,
so this may [likely] be reproduce-able on some system configurations.

This was reported via:
  
https://lore.kernel.org/linux-iio/CA+U=DsrsvGgXEF30-vXuXS_k=-mjsjibweezwkb1hjvn1p9...@mail.gmail.com/T/#u

Fixes: 15097c7a1adc ("iio: buffer: wrap all buffer attributes into 
iio_dev_attr")
Reported-by: Marek Szyprowski  
Signed-off-by: Alexandru Ardelean 
---

@Marek: could you maybe test this on your setup?

I haven't been able to reproduce this on mine.

Thanks
Alex

 drivers/iio/industrialio-buffer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/industrialio-buffer.c 
b/drivers/iio/industrialio-buffer.c
index ee5aab9d4a23..06b2ea087408 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -1309,6 +1309,7 @@ static struct attribute *iio_buffer_wrap_attr(struct 
iio_buffer *buffer,
iio_attr->buffer = buffer;
memcpy(_attr->dev_attr, dattr, sizeof(iio_attr->dev_attr));
iio_attr->dev_attr.attr.name = kstrdup_const(attr->name, GFP_KERNEL);
+   sysfs_attr_init(_attr->dev_attr.attr);
 
list_add(_attr->l, >buffer_attr_list);
 
-- 
2.30.2



Re: [PATCH v1 0/2] Add imx8m power domain driver

2021-04-02 Thread Abel Vesa
On 21-04-02 18:45:04, Adrien Grassein wrote:
> Hi,
> 
> this patch et aims to add the support of the i.MX 8 Power Domain driver.
> Some devices (like usbotg2) can't work without this patch as their
> attached power domain are down.
> 
> The original drivr was taken from le imx kernel and aapted to fit with
> the actual mainline (minor fixes).
> 
> Thanks,
> 

Big NACK for the whole series.

This approach has already been rejected upstream.

Plus, you changed the original author, this work was originally done by Jacky 
Bai.

> Adrien Grassein (2):
>   dt-bindings: power: Add documentation for imx8m power domain driver
>   soc: imx: add Power Domain driver for i.MX8M(M|N|P)
> 
>  .../bindings/power/fsl,imx-power-domain.yaml  |  89 +++
>  MAINTAINERS   |  10 +
>  drivers/soc/imx/Kconfig   |   7 +
>  drivers/soc/imx/Makefile  |   1 +
>  drivers/soc/imx/imx8m_pm_domains.c| 233 ++
>  include/dt-bindings/power/imx8mm-power.h  |  21 ++
>  include/dt-bindings/power/imx8mn-power.h  |  15 ++
>  include/dt-bindings/power/imx8mp-power.h  |  28 +++
>  include/soc/imx/imx_sip.h |  12 +
>  9 files changed, 416 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/power/fsl,imx-power-domain.yaml
>  create mode 100644 drivers/soc/imx/imx8m_pm_domains.c
>  create mode 100644 include/dt-bindings/power/imx8mm-power.h
>  create mode 100644 include/dt-bindings/power/imx8mn-power.h
>  create mode 100644 include/dt-bindings/power/imx8mp-power.h
>  create mode 100644 include/soc/imx/imx_sip.h
> 
> -- 
> 2.25.1
> 


Re: [PATCH v5 15/19] regulator: Support ROHM BD71815 regulators

2021-04-02 Thread Mark Brown
On Mon, Mar 29, 2021 at 03:59:51PM +0300, Matti Vaittinen wrote:

Acked-by: Mark Brown 

but...

> @@ -0,0 +1,676 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright 2014 Embest Technology Co. Ltd. Inc.

Please make the entire comment a C++ one so things look more
intentional.

> +#include 
> +#include 

A regulator driver generally shouldn't need machine interfaces...

> + ret = regulator_enable_regmap(rdev);
> + else
> + ret = regulator_disable_regmap(rdev);
> +
> + if (ret)
> + dev_err(rdev_get_dev(rdev),
> + "LED status error\n");

Better to print the error code, and that error message could be a bit
more descriptive.


signature.asc
Description: PGP signature


[PATCH] net: broadcom: bcm4908enet: Fix a double free in bcm4908_enet_dma_alloc

2021-04-02 Thread Lv Yunlong
In bcm4908_enet_dma_alloc, if callee bcm4908_dma_alloc_buf_descs() failed,
it will free the ring->cpu_addr by dma_free_coherent() and return error.
Then bcm4908_enet_dma_free() will be called, and free the same cpu_addr
by dma_free_coherent() again.

My patch set ring->cpu_addr to NULL after it is freed in
bcm4908_dma_alloc_buf_descs() to avoid the double free.

Fixes: 4feffeadbcb2e ("net: broadcom: bcm4908enet: add BCM4908 controller 
driver")
Signed-off-by: Lv Yunlong 
---
 drivers/net/ethernet/broadcom/bcm4908_enet.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c 
b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index 0b70e9e0ddad..32058386e74b 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -172,6 +172,7 @@ static int bcm4908_dma_alloc_buf_descs(struct bcm4908_enet 
*enet,
 
 err_free_buf_descs:
dma_free_coherent(dev, size, ring->cpu_addr, ring->dma_addr);
+   ring->cpu_addr = NULL;
return -ENOMEM;
 }
 
-- 
2.25.1




Re: [PATCH v2 0/9] KVM: my debug patch queue

2021-04-02 Thread Paolo Bonzini

On 01/04/21 15:54, Maxim Levitsky wrote:

Hi!

I would like to publish two debug features which were needed for other stuff
I work on.

One is the reworked lx-symbols script which now actually works on at least
gdb 9.1 (gdb 9.2 was reported to fail to load the debug symbols from the kernel
for some reason, not related to this patch) and upstream qemu.


Queued patches 2-5 for now.  6 is okay but it needs a selftest. (e.g. 
using KVM_VCPU_SET_EVENTS) and the correct name for the constant.


Paolo


The other feature is the ability to trap all guest exceptions (on SVM for now)
and see them in kvmtrace prior to potential merge to double/triple fault.

This can be very useful and I already had to manually patch KVM a few
times for this.
I will, once time permits, implement this feature on Intel as well.

V2:

  * Some more refactoring and workarounds for lx-symbols script

  * added KVM_GUESTDBG_BLOCKEVENTS flag to enable 'block interrupts on
single step' together with KVM_CAP_SET_GUEST_DEBUG2 capability
to indicate which guest debug flags are supported.

This is a replacement for unconditional block of interrupts on single
step that was done in previous version of this patch set.
Patches to qemu to use that feature will be sent soon.

  * Reworked the the 'intercept all exceptions for debug' feature according
to the review feedback:

- renamed the parameter that enables the feature and
  moved it to common kvm module.
  (only SVM part is currently implemented though)

- disable the feature for SEV guests as was suggested during the review
- made the vmexit table const again, as was suggested in the review as well.

Best regards,
Maxim Levitsky

Maxim Levitsky (9):
   scripts/gdb: rework lx-symbols gdb script
   KVM: introduce KVM_CAP_SET_GUEST_DEBUG2
   KVM: x86: implement KVM_CAP_SET_GUEST_DEBUG2
   KVM: aarch64: implement KVM_CAP_SET_GUEST_DEBUG2
   KVM: s390x: implement KVM_CAP_SET_GUEST_DEBUG2
   KVM: x86: implement KVM_GUESTDBG_BLOCKEVENTS
   KVM: SVM: split svm_handle_invalid_exit
   KVM: x86: add force_intercept_exceptions_mask
   KVM: SVM: implement force_intercept_exceptions_mask

  Documentation/virt/kvm/api.rst|   4 +
  arch/arm64/include/asm/kvm_host.h |   4 +
  arch/arm64/kvm/arm.c  |   2 +
  arch/arm64/kvm/guest.c|   5 -
  arch/s390/include/asm/kvm_host.h  |   4 +
  arch/s390/kvm/kvm-s390.c  |   3 +
  arch/x86/include/asm/kvm_host.h   |  12 ++
  arch/x86/include/uapi/asm/kvm.h   |   1 +
  arch/x86/kvm/svm/svm.c|  87 +++--
  arch/x86/kvm/svm/svm.h|   6 +-
  arch/x86/kvm/x86.c|  14 ++-
  arch/x86/kvm/x86.h|   2 +
  include/uapi/linux/kvm.h  |   1 +
  kernel/module.c   |   8 +-
  scripts/gdb/linux/symbols.py  | 203 --
  15 files changed, 272 insertions(+), 84 deletions(-)





Re: [PATCH 6/8] drivers: firmware: efi: libstub: enable generic commandline

2021-04-02 Thread Christophe Leroy




Le 30/03/2021 à 19:57, Daniel Walker a écrit :

This adds code to handle the generic command line changes.
The efi code appears that it doesn't benefit as much from this design
as it could.

For example, if you had a prepend command line with "nokaslr" then
you might be helpful to re-enable it in the boot loader or dts,
but there appears to be no way to re-enable kaslr or some of the
other options.

Cc: xe-linux-exter...@cisco.com
Signed-off-by: Daniel Walker 
---
  .../firmware/efi/libstub/efi-stub-helper.c| 35 +++
  drivers/firmware/efi/libstub/efi-stub.c   |  7 
  drivers/firmware/efi/libstub/efistub.h|  1 +
  drivers/firmware/efi/libstub/x86-stub.c   | 13 +--
  4 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c 
b/drivers/firmware/efi/libstub/efi-stub-helper.c
index aa8da0a49829..c155837cedc9 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -13,6 +13,7 @@
  #include 
  #include 
  #include  /* For CONSOLE_LOGLEVEL_* */
+#include 
  #include 
  #include 
  
@@ -172,6 +173,40 @@ int efi_printk(const char *fmt, ...)

return printed;
  }
  
+/**

+ * efi_handle_cmdline() - handle adding in building parts of the command line
+ * @cmdline:   kernel command line
+ *
+ * Add in the generic parts of the commandline and start the parsing of the
+ * command line.
+ *
+ * Return: status code
+ */
+efi_status_t efi_handle_cmdline(char const *cmdline)
+{
+   efi_status_t status;
+
+   status = efi_parse_options(CMDLINE_PREPEND);
+   if (status != EFI_SUCCESS) {
+   efi_err("Failed to parse options\n");
+   return status;
+   }
+
+   status = efi_parse_options(IS_ENABLED(CONFIG_CMDLINE_OVERRIDE) ? "" : 
cmdline);
+   if (status != EFI_SUCCESS) {
+   efi_err("Failed to parse options\n");
+   return status;
+   }
+
+   status = efi_parse_options(CMDLINE_APPEND);
+   if (status != EFI_SUCCESS) {
+   efi_err("Failed to parse options\n");
+   return status;
+   }
+
+   return EFI_SUCCESS;
+}


I think we can refactor to first build the final command line, then call efi_parse_options() only 
once after that.


The big advantage of GENERIC_CMDLINE should be to not address anymore CONFIG_CMDLINE_XXX options at 
all outside of linux/cmdline.h



+
  /**
   * efi_parse_options() - Parse EFI command line options
   * @cmdline:  kernel command line
diff --git a/drivers/firmware/efi/libstub/efi-stub.c 
b/drivers/firmware/efi/libstub/efi-stub.c
index 26e69788f27a..760480248adf 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -172,6 +172,12 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
goto fail;
}
  
+#ifdef CONFIG_GENERIC_CMDLINE

+   status = efi_handle_cmdline(cmdline_ptr);
+   if (status != EFI_SUCCESS) {
+   goto fail_free_cmdline;
+   }
+#else


Why an alternative ?


if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
cmdline_size == 0) {
@@ -189,6 +195,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
goto fail_free_cmdline;
}
}
+#endif
  
  	efi_info("Booting Linux Kernel...\n");
  
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h

index cde0a2ef507d..07c7f9fdfffc 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -800,6 +800,7 @@ efi_status_t efi_relocate_kernel(unsigned long *image_addr,
 unsigned long alignment,
 unsigned long min_addr);
  
+efi_status_t efi_handle_cmdline(char const *cmdline);

  efi_status_t efi_parse_options(char const *cmdline);
  
  void efi_parse_option_graphics(char *option);

diff --git a/drivers/firmware/efi/libstub/x86-stub.c 
b/drivers/firmware/efi/libstub/x86-stub.c
index f14c4ff5839f..30ad8fb7122d 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -673,6 +673,8 @@ unsigned long efi_main(efi_handle_t handle,
unsigned long bzimage_addr = (unsigned long)startup_32;
unsigned long buffer_start, buffer_end;
struct setup_header *hdr = _params->hdr;
+   unsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr |
+  ((u64)boot_params->ext_cmd_line_ptr << 
32));
efi_status_t status;
  
  	efi_system_table = sys_table_arg;

@@ -735,6 +737,14 @@ unsigned long efi_main(efi_handle_t handle,
image_offset = 0;
}
  
+#ifdef CONFIG_GENERIC_CMDLINE

+   status = efi_handle_cmdline((char *)cmdline_paddr);
+   if (status != EFI_SUCCESS) {
+   efi_err("Failed to parse 

[PATCH] net: initialize local variables in net/ipv6/mcast.c and net/ipv4/igmp.c

2021-04-02 Thread Phillip Potter
Use memset to initialize two local buffers in net/ipv6/mcast.c,
and another in net/ipv4/igmp.c. Fixes a KMSAN found uninit-value
bug reported by syzbot at:
https://syzkaller.appspot.com/bug?id=0766d38c656abeace60621896d705743aeefed51

Reported-by: syzbot+001516d86dbe88862...@syzkaller.appspotmail.com
Signed-off-by: Phillip Potter 
---
 net/ipv4/igmp.c  | 2 ++
 net/ipv6/mcast.c | 4 
 2 files changed, 6 insertions(+)

diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 7b272bbed2b4..bc8e358a9a2a 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1131,6 +1131,8 @@ static void ip_mc_filter_add(struct in_device *in_dev, 
__be32 addr)
char buf[MAX_ADDR_LEN];
struct net_device *dev = in_dev->dev;
 
+   memset(buf, 0, sizeof(buf));
+
/* Checking for IFF_MULTICAST here is WRONG-WRONG-WRONG.
   We will get multicast token leakage, when IFF_MULTICAST
   is changed. This check should be done in ndo_set_rx_mode
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 6c8604390266..ad90dc28f318 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -658,6 +658,8 @@ static void igmp6_group_added(struct ifmcaddr6 *mc)
struct net_device *dev = mc->idev->dev;
char buf[MAX_ADDR_LEN];
 
+   memset(buf, 0, sizeof(buf));
+
if (IPV6_ADDR_MC_SCOPE(>mca_addr) <
IPV6_ADDR_SCOPE_LINKLOCAL)
return;
@@ -694,6 +696,8 @@ static void igmp6_group_dropped(struct ifmcaddr6 *mc)
struct net_device *dev = mc->idev->dev;
char buf[MAX_ADDR_LEN];
 
+   memset(buf, 0, sizeof(buf));
+
if (IPV6_ADDR_MC_SCOPE(>mca_addr) <
IPV6_ADDR_SCOPE_LINKLOCAL)
return;
-- 
2.30.2



Re: [PATCH V2 1/5] arm64: dts: qcom: pm7325: Add PMIC peripherals for pm7325

2021-04-02 Thread Matthias Kaehlcke
On Thu, Apr 01, 2021 at 02:43:12PM +0530, satya priya wrote:

> subject: arm64: dts: qcom: pm7325: Add PMIC peripherals for pm7325

nit: maybe just 'arm64: dts: qcom: Add pm7325 support/.dtsi' or similar?

> Add temp-alarm and GPIO support for pm7325.

nit: it's more than that, you are adding the .dtsi for the PMIC itself.

> Signed-off-by: satya priya 
> ---
>  arch/arm64/boot/dts/qcom/pm7325.dtsi | 53 
> 
>  1 file changed, 53 insertions(+)
>  create mode 100644 arch/arm64/boot/dts/qcom/pm7325.dtsi
> 
> diff --git a/arch/arm64/boot/dts/qcom/pm7325.dtsi 
> b/arch/arm64/boot/dts/qcom/pm7325.dtsi
> new file mode 100644
> index 000..1e0848a
> --- /dev/null
> +++ b/arch/arm64/boot/dts/qcom/pm7325.dtsi
> @@ -0,0 +1,53 @@
> +// SPDX-License-Identifier: BSD-3-Clause
> +// Copyright (c) 2021, The Linux Foundation. All rights reserved.
> +
> +#include 
> +#include 
> +
> +_bus {
> + pm7325: pmic@1 {
> + compatible = "qcom,pm7325", "qcom,spmi-pmic";

I saw the patches that add the compatible strings for the GPIOs, but
can't find those that add the strings for the PMICs themselves. Could
you provide a link if they have been sent already?

> + reg = <0x1 SPMI_USID>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + pm7325_temp_alarm: temp-alarm@a00 {
> + compatible = "qcom,spmi-temp-alarm";
> + reg = <0xa00>;
> + interrupts = <0x1 0xa 0x0 IRQ_TYPE_EDGE_BOTH>;
> + #thermal-sensor-cells = <0>;
> + };
> +
> + pm7325_gpios: gpios@8800 {
> + compatible = "qcom,pm7325-gpio", "qcom,spmi-gpio";
> + reg = <0x8800>;
> + gpio-controller;
> + gpio-ranges = <_gpios 0 0 10>;
> + #gpio-cells = <2>;
> + interrupt-controller;
> + #interrupt-cells = <2>;
> + };
> + };
> +};
> +
> +_zones {
> + pm7325_thermal: pm7325-thermal {
> + polling-delay-passive = <100>;
> + polling-delay = <0>;
> + thermal-sensors = <_temp_alarm>;
> +
> + trips {
> + pm7325_trip0: trip0 {
> + temperature = <95000>;
> + hysteresis = <0>;
> + type = "passive";
> + };
> +
> + pm7325_trip1: trip1 {

nit: the critical trip point is often named -crit. One reason for
this could be that it allows to add other non-critical trip points (in
the .dtsi itself or the .dts), without messing up the
enumeration scheme.

> + temperature = <115000>;
> + hysteresis = <0>;
> + type = "critical";
> + };
> + };
> + };
> +};


Re: [PATCH 4/8] CMDLINE: powerpc: convert to generic builtin command line

2021-04-02 Thread Christophe Leroy




Le 30/03/2021 à 19:56, Daniel Walker a écrit :

This updates the powerpc code to use the CONFIG_GENERIC_CMDLINE
option.

This includes a scripted mass convert of the config files to use
the new generic cmdline. There is a bit of a trim effect here.
It would seems that some of the config haven't been trimmed in
a while.


Sorry, this patch is not acceptable as is, the default for powerpc is CMDLINE_FROM_BOOTLOADER, ie 
builtin-cmdline is taken if and only if none is provided by the bootloader.


As far as I understand, that disappear with this patch.



The bash script used to convert is as follows,

if [[ -z "$1" || -z "$2" ]]; then
 echo "Two arguments are needed."
 exit 1
fi
mkdir $1
cp $2 $1/.config
sed -i 's/CONFIG_CMDLINE=/CONFIG_CMDLINE_BOOL=y\nCONFIG_CMDLINE_PREPEND=/g' 
$1/.config
make ARCH=$1 O=$1 olddefconfig
make ARCH=$1 O=$1 savedefconfig
cp $1/defconfig $2
rm -Rf $1

Cc: xe-linux-exter...@cisco.com
Signed-off-by: Ruslan Ruslichenko 
Signed-off-by: Ruslan Bilovol 
Signed-off-by: Daniel Walker 
---
  arch/powerpc/Kconfig  | 38 +--
  arch/powerpc/configs/44x/fsp2_defconfig   | 32 
  arch/powerpc/configs/44x/iss476-smp_defconfig | 24 ++--
  arch/powerpc/configs/44x/warp_defconfig   | 17 -
  arch/powerpc/configs/holly_defconfig  | 13 ---
  arch/powerpc/configs/mvme5100_defconfig   | 23 +--
  arch/powerpc/configs/skiroot_defconfig| 12 +++---
  arch/powerpc/configs/storcenter_defconfig | 18 -
  arch/powerpc/kernel/prom_init.c   | 10 +++--
  9 files changed, 74 insertions(+), 113 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 386ae12d8523..3a19e5b74177 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -167,6 +167,8 @@ config PPC
select EDAC_SUPPORT
select GENERIC_ATOMIC64 if PPC32
select GENERIC_CLOCKEVENTS_BROADCASTif SMP
+   select GENERIC_CMDLINE
+   select GENERIC_CMDLINE_OF
select GENERIC_CMOS_UPDATE
select GENERIC_CPU_AUTOPROBE
select GENERIC_CPU_VULNERABILITIES  if PPC_BARRIER_NOSPEC
@@ -886,42 +888,6 @@ config PPC_DENORMALISATION
  Add support for handling denormalisation of single precision
  values.  Useful for bare metal only.  If unsure say Y here.
  
-config CMDLINE

-   string "Initial kernel command string"
-   default ""
-   help
- On some platforms, there is currently no way for the boot loader to
- pass arguments to the kernel. For these platforms, you can supply
- some command-line options at build time by entering them here.  In
- most cases you will need to specify the root device here.
-
-choice
-   prompt "Kernel command line type" if CMDLINE != ""
-   default CMDLINE_FROM_BOOTLOADER
-
-config CMDLINE_FROM_BOOTLOADER
-   bool "Use bootloader kernel arguments if available"
-   help
- Uses the command-line options passed by the boot loader. If
- the boot loader doesn't provide any, the default kernel command
- string provided in CMDLINE will be used.
-
-config CMDLINE_EXTEND
-   bool "Extend bootloader kernel arguments"
-   help
- The command-line arguments provided by the boot loader will be
- appended to the default kernel command string.
-
-config CMDLINE_FORCE
-   bool "Always use the default kernel command string"
-   help
- Always use the default kernel command string, even if the boot
- loader passes other arguments to the kernel.
- This is useful if you cannot or don't want to change the
- command-line options your boot loader passes to the kernel.
-
-endchoice
-
  config EXTRA_TARGETS
string "Additional default image types"
help
diff --git a/arch/powerpc/configs/44x/fsp2_defconfig 
b/arch/powerpc/configs/44x/fsp2_defconfig
index 8da316e61a08..4993db054589 100644
--- a/arch/powerpc/configs/44x/fsp2_defconfig
+++ b/arch/powerpc/configs/44x/fsp2_defconfig
@@ -1,8 +1,6 @@
-CONFIG_44x=y
  # CONFIG_SWAP is not set
  CONFIG_SYSVIPC=y
  # CONFIG_CROSS_MEMORY_ATTACH is not set
-# CONFIG_FHANDLE is not set
  CONFIG_NO_HZ=y
  CONFIG_HIGH_RES_TIMERS=y
  CONFIG_IKCONFIG=y
@@ -13,23 +11,25 @@ CONFIG_BLK_DEV_INITRD=y
  # CONFIG_RD_XZ is not set
  # CONFIG_RD_LZO is not set
  # CONFIG_RD_LZ4 is not set
+# CONFIG_FHANDLE is not set
  CONFIG_KALLSYMS_ALL=y
  CONFIG_BPF_SYSCALL=y
  CONFIG_EMBEDDED=y
  CONFIG_PROFILING=y
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_BLK_DEV_BSG is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE_PREPEND="ip=on rw"
+CONFIG_44x=y
  CONFIG_PPC_47x=y
  # CONFIG_EBONY is not set
  CONFIG_FSP2=y
  CONFIG_476FPE_ERR46=y
-CONFIG_SWIOTLB=y
  CONFIG_KEXEC=y
  CONFIG_CRASH_DUMP=y
-CONFIG_CMDLINE="ip=on rw"
  # CONFIG_SUSPEND is not set
-# CONFIG_PCI is not set
+CONFIG_OPROFILE=y
+CONFIG_MODULES=y

Re: [PATCH v5 14/19] regulator: bd718x7, bd71828: Use ramp-delay helper

2021-04-02 Thread Mark Brown
On Mon, Mar 29, 2021 at 03:59:28PM +0300, Matti Vaittinen wrote:
> Use generic regamp ramp-delay helper function instead of implementing own.
> 

Acked-by: Mark Brown 


signature.asc
Description: PGP signature


Re: [PATCH 3/8] powerpc: convert strcpy to strlcpy in prom_init

2021-04-02 Thread Christophe Leroy




Le 30/03/2021 à 19:56, Daniel Walker a écrit :

There's only two users of strcpy and one is the command
line handling. The generic command line handling uses strlcpy
and it makes sense to convert this one other user to strlcpy to
keep prom_init size consistent.

Cc: xe-linux-exter...@cisco.com
Signed-off-by: Daniel Walker 


Reviewed-by: Christophe Leroy 


---
  arch/powerpc/kernel/prom_init.c | 25 +++--
  1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index ccf77b985c8f..2c2f33155317 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -242,15 +242,6 @@ static int __init prom_strcmp(const char *cs, const char 
*ct)
return 0;
  }
  
-static char __init *prom_strcpy(char *dest, const char *src)

-{
-   char *tmp = dest;
-
-   while ((*dest++ = *src++) != '\0')
-   /* nothing */;
-   return tmp;
-}
-
  static int __init prom_strncmp(const char *cs, const char *ct, size_t count)
  {
unsigned char c1, c2;
@@ -276,6 +267,20 @@ static size_t __init prom_strlen(const char *s)
return sc - s;
  }
  
+static size_t __init prom_strlcpy(char *dest, const char *src, size_t size)

+{
+   size_t ret = prom_strlen(src);
+
+   if (size) {
+   size_t len = (ret >= size) ? size - 1 : ret;
+
+   memcpy(dest, src, len);
+   dest[len] = '\0';
+   }
+   return ret;
+}
+
+
  static int __init prom_memcmp(const void *cs, const void *ct, size_t count)
  {
const unsigned char *su1, *su2;
@@ -2702,7 +2707,7 @@ static void __init flatten_device_tree(void)
  
  	/* Add "phandle" in there, we'll need it */

namep = make_room(_start, _end, 16, 1);
-   prom_strcpy(namep, "phandle");
+   prom_strlcpy(namep, "phandle", 8);
mem_start = (unsigned long)namep + prom_strlen(namep) + 1;
  
  	/* Build string array */




Re: [PATCH 2/8] CMDLINE: drivers: of: ifdef out cmdline section

2021-04-02 Thread Christophe Leroy




Le 30/03/2021 à 19:56, Daniel Walker a écrit :

It looks like there's some seepage of cmdline stuff into
the generic device tree code. This conflicts with the
generic cmdline implementation so I remove it in the case
when that's enabled.

Cc: xe-linux-exter...@cisco.com
Signed-off-by: Ruslan Ruslichenko 
Signed-off-by: Daniel Walker 
---
  drivers/of/fdt.c | 14 ++
  1 file changed, 14 insertions(+)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index dcc1dd96911a..d8805cd9717a 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -25,6 +25,7 @@
  #include 
  #include 
  #include 
+#include 
  
  #include   /* for COMMAND_LINE_SIZE */

  #include 
@@ -1050,6 +1051,18 @@ int __init early_init_dt_scan_chosen(unsigned long node, 
const char *uname,
  
  	/* Retrieve command line */

p = of_get_flat_dt_prop(node, "bootargs", );
+
+#if defined(CONFIG_GENERIC_CMDLINE) && defined(CONFIG_GENERIC_CMDLINE_OF)
+   /*
+* The builtin command line will be added here, or it can override
+* with the DT bootargs.
+*/
+   cmdline_add_builtin(data,
+   (l > 0 ? p : NULL), /* This is sanity checking */
+   COMMAND_LINE_SIZE);
+#elif defined(CONFIG_GENERIC_CMDLINE)
+   strlcpy(data, p, COMMAND_LINE_SIZE);
+#else


Ugly.

Linux codying style recommend to limit the use of #ifdefs to headers as much as 
possible.

Why do we need so many alternatives ? Allthough they are temporary, can we order the changes in 
another way to reduce that ?



if (p != NULL && l > 0)
strlcpy(data, p, min(l, COMMAND_LINE_SIZE));
  
@@ -1070,6 +1083,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,

strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
  #endif
  #endif /* CONFIG_CMDLINE */
+#endif /* CONFIG_GENERIC_CMDLINE */
  
  	pr_debug("Command line is: %s\n", (char *)data);
  



Re: [PATCH v5 11/19] regulator: rohm-regulator: linear voltage support

2021-04-02 Thread Mark Brown
On Mon, Mar 29, 2021 at 03:58:03PM +0300, Matti Vaittinen wrote:
> The helper for obtaining HW-state based DVS voltage levels currently only
> works for regulators using linear-ranges. Extend support to regulators with
> simple linear mappings and add also proper error path if pickable-ranges
> regulators call this.

Acked-by: Mark Brown 


signature.asc
Description: PGP signature


Re: [PATCH v5 12/19] regulator: rohm-regulator: Support SNVS HW state.

2021-04-02 Thread Mark Brown
On Mon, Mar 29, 2021 at 03:58:33PM +0300, Matti Vaittinen wrote:
> The ROHM BD71815 supports setting voltage levels/regulator status
> for HW-states "RUN", "SUSPEND", "LPSR" and "SNVS". Add DT parsing
> helper also for SNVS state.

Acked-by: Mark Brown 


signature.asc
Description: PGP signature


[PATCH v2 30/30] staging: rtl8723bs: add spaces around operators

2021-04-02 Thread Fabio Aiuto
fix post-commit hook checkpatch issues:

CHECK: spaces preferred around that '+' (ctx:VxV)
161: FILE: drivers/staging/rtl8723bs/core/rtw_ieee80211.c:648:
+   *wpa_len = in_ie[cnt+1]+2;
^

CHECK: spaces preferred around that '+' (ctx:VxV)
161: FILE: drivers/staging/rtl8723bs/core/rtw_ieee80211.c:648:
+   *wpa_len = in_ie[cnt+1]+2;
   ^

CHECK: spaces preferred around that '+' (ctx:VxV)
162: FILE: drivers/staging/rtl8723bs/core/rtw_ieee80211.c:649:
+   cnt += in_ie[cnt+1]+2;  /* get next */
^

CHECK: spaces preferred around that '+' (ctx:VxV)
162: FILE: drivers/staging/rtl8723bs/core/rtw_ieee80211.c:649:
+   cnt += in_ie[cnt+1]+2;  /* get next */
   ^

Signed-off-by: Fabio Aiuto 
---
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index eb2058f2d139..a0d664e254a8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -645,8 +645,8 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 
*rsn_len, u8 *wpa_ie
if (wpa_ie)
memcpy(wpa_ie, _ie[cnt], in_ie[cnt+1]+2);
 
-   *wpa_len = in_ie[cnt+1]+2;
-   cnt += in_ie[cnt+1]+2;  /* get next */
+   *wpa_len = in_ie[cnt + 1] + 2;
+   cnt += in_ie[cnt + 1] + 2;  /* get next */
} else {
if (authmode == WLAN_EID_RSN) {
if (rsn_ie)
-- 
2.20.1



[PATCH v2 29/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_ieee80211.c

2021-04-02 Thread Fabio Aiuto
remove all RT_TRACE logs

Signed-off-by: Fabio Aiuto 
---
 .../staging/rtl8723bs/core/rtw_ieee80211.c| 90 ---
 1 file changed, 15 insertions(+), 75 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index e931afc3ba22..eb2058f2d139 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -488,11 +488,8 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int 
*group_cipher, int *pairwis
pos += WPA_SELECTOR_LEN;
left -= WPA_SELECTOR_LEN;
 
-   } else if (left > 0) {
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie length 
mismatch, %u too much", __func__, left));
-
+   } else if (left > 0)
return _FAIL;
-   }
 
/* pairwise_cipher */
if (left >= 2) {
@@ -501,11 +498,8 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int 
*group_cipher, int *pairwis
pos += 2;
left -= 2;
 
-   if (count == 0 || left < count * WPA_SELECTOR_LEN) {
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie 
count botch (pairwise), "
-   "count %u left %u", __func__, 
count, left));
+   if (count == 0 || left < count * WPA_SELECTOR_LEN)
return _FAIL;
-   }
 
for (i = 0; i < count; i++) {
*pairwise_cipher |= rtw_get_wpa_cipher_suite(pos);
@@ -514,16 +508,13 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int 
*group_cipher, int *pairwis
left -= WPA_SELECTOR_LEN;
}
 
-   } else if (left == 1) {
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short 
(for key mgmt)",   __func__));
+   } else if (left == 1)
return _FAIL;
-   }
 
if (is_8021x) {
if (left >= 6) {
pos += 2;
if (!memcmp(pos, SUITE_1X, 4)) {
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, 
("%s : there has 802.1x auth\n", __func__));
*is_8021x = 1;
}
}
@@ -559,10 +550,8 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int 
*group_cipher, int *pairwi
pos += RSN_SELECTOR_LEN;
left -= RSN_SELECTOR_LEN;
 
-   } else if (left > 0) {
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie length 
mismatch, %u too much", __func__, left));
+   } else if (left > 0)
return _FAIL;
-   }
 
/* pairwise_cipher */
if (left >= 2) {
@@ -571,11 +560,8 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int 
*group_cipher, int *pairwi
pos += 2;
left -= 2;
 
-   if (count == 0 || left < count * RSN_SELECTOR_LEN) {
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie 
count botch (pairwise), "
-"count %u left %u", __func__, 
count, left));
+   if (count == 0 || left < count * RSN_SELECTOR_LEN)
return _FAIL;
-   }
 
for (i = 0; i < count; i++) {
*pairwise_cipher |= rtw_get_wpa2_cipher_suite(pos);
@@ -584,19 +570,14 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int 
*group_cipher, int *pairwi
left -= RSN_SELECTOR_LEN;
}
 
-   } else if (left == 1) {
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short 
(for key mgmt)",  __func__));
-
+   } else if (left == 1)
return _FAIL;
-   }
 
if (is_8021x) {
if (left >= 6) {
pos += 2;
-   if (!memcmp(pos, SUITE_1X, 4)) {
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, 
("%s (): there has 802.1x auth\n", __func__));
+   if (!memcmp(pos, SUITE_1X, 4))
*is_8021x = 1;
-   }
}
}
 
@@ -607,7 +588,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int 
*group_cipher, int *pairwi
 int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len)
 {
int len = 0;
-   u8 authmode, i;
+   u8 authmode;
uintcnt;
u8 wapi_oui1[4] = {0x0, 0x14, 0x72, 0x01};
u8 wapi_oui2[4] = {0x0, 0x14, 0x72, 0x02};
@@ -626,16 +607,9 @@ int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, 
u16 *wapi_len)
/* if (authmode == WLAN_EID_BSS_AC_ACCESS_DELAY) */
if (authmode == WLAN_EID_BSS_AC_ACCESS_DELAY && 
(!memcmp(_ie[cnt+6], wapi_oui1, 4) ||
!memcmp(_ie[cnt+6], wapi_oui2, 

[PATCH v2 28/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_sta_mgt.c

2021-04-02 Thread Fabio Aiuto
remove all RT_TRACE logs

Signed-off-by: Fabio Aiuto 
---
 drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 25 
 1 file changed, 25 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c 
b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
index f96dd0b40e04..7dcac4dd9de2 100644
--- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
@@ -216,10 +216,7 @@ struct sta_info *rtw_alloc_stainfo(struct  
sta_priv *pstapriv, u8 *hwaddr)
 
index = wifi_mac_hash(hwaddr);
 
-   RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, 
("rtw_alloc_stainfo: index  = %x", index));
-
if (index >= NUM_STA) {
-   RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("ERROR 
=> rtw_alloc_stainfo: index >= NUM_STA"));
spin_unlock_bh(&(pstapriv->sta_hash_lock));
psta = NULL;
goto exit;
@@ -242,17 +239,6 @@ struct sta_info *rtw_alloc_stainfo(struct  
sta_priv *pstapriv, u8 *hwaddr)
for (i = 0; i < 16; i++)
memcpy(>sta_recvpriv.rxcache.tid_rxseq[i], 
, 2);
 
-   RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_,
-("alloc number_%d stainfo  with hwaddr = %x %x %x %x 
%x %x \n",
- pstapriv->asoc_sta_count,
- hwaddr[0],
- hwaddr[1],
- hwaddr[2],
- hwaddr[3],
- hwaddr[4],
- hwaddr[5])
-   );
-
init_addba_retry_timer(pstapriv->padapter, psta);
 
/* for A-MPDU Rx reordering buffer control */
@@ -363,16 +349,6 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct 
sta_info *psta)
spin_unlock_bh(>lock);
 
list_del_init(>hash_list);
-   RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_,
-("\n free number_%d stainfo  with hwaddr = 0x%.2x 0x%.2x 
0x%.2x 0x%.2x 0x%.2x 0x%.2x \n",
- pstapriv->asoc_sta_count,
- psta->hwaddr[0],
- psta->hwaddr[1],
- psta->hwaddr[2],
- psta->hwaddr[3],
- psta->hwaddr[4],
- psta->hwaddr[5])
-   );
pstapriv->asoc_sta_count--;
 
/*  re-init sta_info; 20061114 will be init in alloc_stainfo */
@@ -543,7 +519,6 @@ u32 rtw_init_bcmc_stainfo(struct adapter *padapter)
 
if (!psta) {
res = _FAIL;
-   RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, 
("rtw_alloc_stainfo fail"));
goto exit;
}
 
-- 
2.20.1



Re: [RESEND PATCH v4 0/3] Introduce the for_each_set_nbits macro

2021-04-02 Thread Andy Shevchenko
On Fri, Apr 2, 2021 at 7:36 PM Syed Nayyar Waris  wrote:
>
> Hello Bartosz,
>
> Since this patchset primarily affects GPIO drivers, would you like
> to pick it up through your GPIO tree?
>
> This patchset introduces a new generic version of for_each_set_nbits.
> The previous version of for_each_set_clump8 used a fixed size 8-bit
> clump, but the new generic version can work with clump of any size but

clumps

> less than or equal to BITS_PER_LONG. The patchset utilizes the new macro
> in several GPIO drivers.
>
> The earlier 8-bit for_each_set_clump8 facilitated a
> for-loop syntax that iterates over a memory region entire groups of set
> bits at a time.
>
> For example, suppose you would like to iterate over a 32-bit integer 8
> bits at a time, skipping over 8-bit groups with no set bit, where
>  represents the current 8-bit group:
>
> Example:1010   00110011
> First loop: 1010   
> Second loop:1010   00110011
> Third loop:    00110011
>
> Each iteration of the loop returns the next 8-bit group that has at
> least one set bit.
>
> But with the new for_each_set_nbits the clump size can be different from 8 
> bits.
> Moreover, the clump can be split at word boundary in situations where word

boundaries

> size is not multiple of clump size. Following are examples showing the working
> of new macro for clump sizes of 24 bits and 6 bits.
>
> Example 1:
> clump size: 24 bits, Number of clumps (or ports): 10
> bitmap stores the bit information from where successive clumps are retrieved.
>
>  /* bitmap memory region */
> 0x00aaff00;  /* Most significant bits */
> 0xaaff;
> 0x00aa00aa;
> 0xabcdeffedcba;  /* Least significant bits */
>
> Different iterations of for_each_set_nbits:-
> 'offset' is the bit position and 'clump' is the 24 bit clump from the
> above bitmap.
> Iteration first:offset: 0 clump: 0xfedcba
> Iteration second:   offset: 24 clump: 0xabcdef
> Iteration third:offset: 48 clump: 0xaa
> Iteration fourth:   offset: 96 clump: 0xaa
> Iteration fifth:offset: 144 clump: 0xff
> Iteration sixth:offset: 168 clump: 0xaa
> Iteration seventh:  offset: 216 clump: 0xff
> Loop breaks because in the end the remaining bits (0x00aa) size was less
> than clump size of 24 bits.
>
> In above example it can be seen that in iteration third, the 24 bit clump
> that was retrieved was split between bitmap[0] and bitmap[1]. This example
> also shows that 24 bit zeroes if present in between, were skipped (preserving
> the previous for_each_set_macro8 behaviour).
>
> Example 2:
> clump size = 6 bits, Number of clumps (or ports) = 3.
>
>  /* bitmap memory region */
> 0x00aaff00;  /* Most significant bits */
> 0xaaff;
> 0x0f00;
> 0x0ac0;  /* Least significant bits */
>
> Different iterations of for_each_set_nbits:
> 'offset' is the bit position and 'clump' is the 6 bit clump from the
> above bitmap.
> Iteration first:offset: 6 clump: 0x2b
> Loop breaks because 6 * 3 = 18 bits traversed in bitmap.
> Here 6 * 3 is clump size * no. of clumps.

Bart, I would like to have a fresh look at this.

(missed changelog)

> Changes in v4:
>  - [Patch 3/3]: Remove extra line and add few comments.
>  - [Patch 3/3]: Use single lock (and unlock) call instead of two
>lock (and two unlock) calls.
>  - [Patch 3/3]: Use bitmap_from_arr32() where applicalble.
>  - [Patch 3/3]: Remove unnecessary 'const'.
>
> Changes in v3:
>  - [Patch 1/3]: Rename for_each_set_clump to for_each_set_nbits.
>  - [Patch 1/3]: Shift function definitions outside 'ifdef CONFIG_DEBUG_FS'
>macro guard to resolve build (linking) error in xilinx Patch[3/3].
>  - [Patch 2/3]: Rename for_each_set_clump to for_each_set_nbits.
>
> Changes in v2:
>  - [Patch 1/3]: Shift the macros and related functions to gpiolib inside
>gpio/. Reduce the visibilty of 'for_each_set_clump' to gpio.
>  - [Patch 1/3]: Remove __builtin_unreachable and simply use return
>statement.
>  - Remove tests from lib/test_bitmap.c as 'for_each_set_clump' is
>now localised inside gpio/ only.
>
> Syed Nayyar Waris (3):
>   gpiolib: Introduce the for_each_set_nbits macro
>   gpio: thunderx: Utilize for_each_set_nbits macro
>   gpio: xilinx: Utilize generic bitmap_get_value and _set_value
>
>  drivers/gpio/gpio-thunderx.c | 13 --
>  drivers/gpio/gpio-xilinx.c   | 52 ++---
>  drivers/gpio/gpiolib.c   | 90 
>  drivers/gpio/gpiolib.h   | 28 +++
>  4 files changed, 152 insertions(+), 31 deletions(-)
>
>
> base-commit: e1b7033ecdac56c1cc4dff72d67cac25d449efc6
> --
> 2.29.0
>


-- 
With Best Regards,
Andy Shevchenko


[PATCH v2 27/30] staging: rtl8723bs: remove all RT_TRACE logs in core/rtw_wlan_util.c

2021-04-02 Thread Fabio Aiuto
remove all RT_TRACE logs

Signed-off-by: Fabio Aiuto 
---
 .../staging/rtl8723bs/core/rtw_wlan_util.c| 24 ---
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c 
b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index 760b0ea4e9bd..f6a7993005ab 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -1334,11 +1334,6 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 
*pframe, u32 packet_len)
memcpy(bssid->Ssid.Ssid, (p + 2), ssid_len);
bssid->Ssid.SsidLength = ssid_len;
 
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s bssid.Ssid.Ssid:%s 
bssid.Ssid.SsidLength:%d "
-   "cur_network->network.Ssid.Ssid:%s len:%d\n", 
__func__, bssid->Ssid.Ssid,
-   bssid->Ssid.SsidLength, 
cur_network->network.Ssid.Ssid,
-   cur_network->network.Ssid.SsidLength));
-
if (memcmp(bssid->Ssid.Ssid, cur_network->network.Ssid.Ssid, 32) ||
bssid->Ssid.SsidLength != 
cur_network->network.Ssid.SsidLength) {
if (bssid->Ssid.Ssid[0] != '\0' && bssid->Ssid.SsidLength != 0) 
{ /* not hidden ssid */
@@ -1355,9 +1350,6 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 
*pframe, u32 packet_len)
else
bssid->Privacy = 0;
 
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-   ("%s(): cur_network->network.Privacy is %d, 
bssid.Privacy is %d\n",
-__func__, cur_network->network.Privacy, 
bssid->Privacy));
if (cur_network->network.Privacy != bssid->Privacy) {
DBG_871X("%s(), privacy is not match\n", __func__);
goto _mismatch;
@@ -1382,25 +1374,17 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 
*pframe, u32 packet_len)
if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == 
ENCRYP_PROTOCOL_WPA2) {
pbuf = rtw_get_wpa_ie(>IEs[12], _ielen, 
bssid->IELength-12);
if (pbuf && (wpa_ielen > 0)) {
-   if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, 
_cipher, _cipher, _8021x)) {
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-   ("%s pnetwork->pairwise_cipher: 
%d, group_cipher is %d, is_8021x is %d\n", __func__,
-pairwise_cipher, group_cipher, 
is_8021x));
-   }
+   rtw_parse_wpa_ie(pbuf, wpa_ielen + 2, _cipher,
+_cipher, _8021x);
} else {
pbuf = rtw_get_wpa2_ie(>IEs[12], _ielen, 
bssid->IELength-12);
 
if (pbuf && (wpa_ielen > 0)) {
-   if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, 
wpa_ielen+2, _cipher, _cipher, _8021x)) {
-   RT_TRACE(_module_rtl871x_mlme_c_, 
_drv_info_,
-   ("%s 
pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_802x is %d\n",
-__func__, 
pairwise_cipher, group_cipher, is_8021x));
-   }
+   rtw_parse_wpa2_ie(pbuf, wpa_ielen + 2, 
_cipher,
+ _cipher, _8021x);
}
}
 
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-   ("%s cur_network->group_cipher is %d: %d\n", 
__func__, cur_network->BcnInfo.group_cipher, group_cipher));
if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || 
group_cipher != cur_network->BcnInfo.group_cipher) {
DBG_871X("%s pairwise_cipher(%x:%x) or 
group_cipher(%x:%x) is not match\n", __func__,
pairwise_cipher, 
cur_network->BcnInfo.pairwise_cipher,
-- 
2.20.1



[PATCH v2 26/30] staging: rtl8723bs: place constant on the right side of the test

2021-04-02 Thread Fabio Aiuto
fix posst-commit checkpatch issues:

WARNING: Comparisons should place the constant on the right
side of the test
40: FILE: drivers/staging/rtl8723bs/core/rtw_ioctl_set.c:71:
+   if (_SUCCESS != ret)

WARNING: Comparisons should place the constant on the right
side of the test
69: FILE: drivers/staging/rtl8723bs/core/rtw_ioctl_set.c:122:
+   if (_SUCCESS != ret)

Signed-off-by: Fabio Aiuto 
---
 drivers/staging/rtl8723bs/core/rtw_ioctl_set.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c 
b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
index d4920d7d2452..f8c7dcb7ab7d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
@@ -68,7 +68,7 @@ u8 rtw_do_join(struct adapter *padapter)
) {
/*  submit site_survey_cmd */
ret = rtw_sitesurvey_cmd(padapter, 
>assoc_ssid, 1, NULL, 0);
-   if (_SUCCESS != ret)
+   if (ret != _SUCCESS)
pmlmepriv->to_join = false;
 
} else {
@@ -119,7 +119,7 @@ u8 rtw_do_join(struct adapter *padapter)
) {
/* DBG_871X("rtw_do_join() when   no 
desired bss in scanning queue\n"); */
ret = rtw_sitesurvey_cmd(padapter, 
>assoc_ssid, 1, NULL, 0);
-   if (_SUCCESS != ret)
+   if (ret != _SUCCESS)
pmlmepriv->to_join = false;
 
} else {
-- 
2.20.1



[PATCH v2 25/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_ioctl_set.c

2021-04-02 Thread Fabio Aiuto
remove all RT_TRACE logs

Signed-off-by: Fabio Aiuto 
---
 .../staging/rtl8723bs/core/rtw_ioctl_set.c| 76 +--
 1 file changed, 4 insertions(+), 72 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c 
b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
index 14eb01df69b0..d4920d7d2452 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
@@ -28,7 +28,6 @@ u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid)
u8 ret = true;
 
if (ssid->SsidLength > 32) {
-   RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid length 
>32\n"));
ret = false;
goto exit;
}
@@ -49,8 +48,6 @@ u8 rtw_do_join(struct adapter *padapter)
phead = get_list_head(queue);
plist = get_next(phead);
 
-   RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("\n rtw_do_join: 
phead = %p; plist = %p\n\n\n", phead, plist));
-
pmlmepriv->cur_network.join_res = -2;
 
set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
@@ -69,13 +66,11 @@ u8 rtw_do_join(struct adapter *padapter)
if (pmlmepriv->LinkDetectInfo.bBusyTraffic == false
|| rtw_to_roam(padapter) > 0
) {
-   RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, 
("rtw_do_join(): site survey if scanned_queue is empty\n."));
/*  submit site_survey_cmd */
ret = rtw_sitesurvey_cmd(padapter, 
>assoc_ssid, 1, NULL, 0);
-   if (_SUCCESS != ret) {
+   if (_SUCCESS != ret)
pmlmepriv->to_join = false;
-   RT_TRACE(_module_rtl871x_ioctl_set_c_, 
_drv_err_, ("rtw_do_join(): site survey return error\n."));
-   }
+
} else {
pmlmepriv->to_join = false;
ret = _FAIL;
@@ -107,15 +102,12 @@ u8 rtw_do_join(struct adapter *padapter)
rtw_generate_random_ibss(pibss);
 
if (rtw_createbss_cmd(padapter) != _SUCCESS) {
-   RT_TRACE(_module_rtl871x_ioctl_set_c_, 
_drv_err_, ("***Error =>do_goin: rtw_createbss_cmd status FAIL***\n "));
ret =  false;
goto exit;
}
 
pmlmepriv->to_join = false;
 
-   RT_TRACE(_module_rtl871x_ioctl_set_c_, 
_drv_info_, ("***Error => rtw_select_and_join_from_scanned_queue FAIL under 
STA_Mode***\n "));
-
} else {
/*  can't associate ; reset under-linking */
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
@@ -127,10 +119,9 @@ u8 rtw_do_join(struct adapter *padapter)
) {
/* DBG_871X("rtw_do_join() when   no 
desired bss in scanning queue\n"); */
ret = rtw_sitesurvey_cmd(padapter, 
>assoc_ssid, 1, NULL, 0);
-   if (_SUCCESS != ret) {
+   if (_SUCCESS != ret)
pmlmepriv->to_join = false;
-   
RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("do_join(): site survey 
return error\n."));
-   }
+
} else {
ret = _FAIL;
pmlmepriv->to_join = false;
@@ -169,16 +160,10 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 
*bssid)
goto release_mlme_lock;
 
if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == 
true) {
-   RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid: 
_FW_LINKED||WIFI_ADHOC_MASTER_STATE\n"));
-
if (!memcmp(>cur_network.network.MacAddress, bssid, 
ETH_ALEN)) {
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == 
false)
goto release_mlme_lock;/* it means driver is in 
WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */
} else {
-   RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, 
("Set BSSID not the same bssid\n"));
-   RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, 
("set_bssid =%pM\n", MAC_ARG(bssid)));
-   RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, 
("cur_bssid =%pM\n", MAC_ARG(pmlmepriv->cur_network.network.MacAddress)));
-
rtw_disassoc_cmd(padapter, 0, true);
 
if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
@@ -212,8 +197,6 @@ u8 

[PATCH v2 24/30] staging: rtl8723bs: remove commented RT_TRACE call in core/rtw_ioctl_set.c

2021-04-02 Thread Fabio Aiuto
remove commented RT_TRACE call in core/rtw_ioctl_set.c

Signed-off-by: Fabio Aiuto 
---
 drivers/staging/rtl8723bs/core/rtw_ioctl_set.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c 
b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
index 7d858cae2395..14eb01df69b0 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
@@ -451,9 +451,6 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter 
*padapter,
 
/* SecClearAllKeys(adapter); */
 
-   /* RT_TRACE(COMP_OID_SET, DBG_LOUD, ("set_infrastructure: 
fw_state:%x after changing mode\n", */
-   /*  
get_fwstate(pmlmepriv))); */
-
spin_unlock_bh(>lock);
}
return true;
-- 
2.20.1



[PATCH v2 22/30] staging: rtl8723bs: remove unnecessary parentheses

2021-04-02 Thread Fabio Aiuto
fix post-commit checkpatch issue:

CHECK: Unnecessary parentheses around
'psecuritypriv->bcheck_grpkey == false'
24: FILE: drivers/staging/rtl8723bs/core/rtw_recv.c:381:
+   if ((psecuritypriv->
bcheck_grpkey == false) &&
+   (IS_MCAST(prxattrib->ra)
 == true))

Signed-off-by: Fabio Aiuto 
---
 drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c 
b/drivers/staging/rtl8723bs/core/rtw_recv.c
index c8a13d733c98..cd4324a93275 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -378,7 +378,7 @@ static signed int recvframe_chkmic(struct adapter *adapter, 
 union recv_frame *p
 
} else {
/* mic checked ok */
-   if ((psecuritypriv->bcheck_grpkey == false) &&
+   if (psecuritypriv->bcheck_grpkey == false &&
(IS_MCAST(prxattrib->ra) == true))
psecuritypriv->bcheck_grpkey = true;
}
-- 
2.20.1



[PATCH v2 21/30] staging: rtl8723bs: split long line

2021-04-02 Thread Fabio Aiuto
fix post-commit hook checkpatch issue:

WARNING: line length of 113 exceeds 100 columns
110: FILE: drivers/staging/rtl8723bs/core/rtw_recv.c:381:
+   if ((psecuritypriv->bcheck_grpkey
 == false) && (IS_MCAST(prxattrib->ra) == true))

Signed-off-by: Fabio Aiuto 
---
 drivers/staging/rtl8723bs/core/rtw_recv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c 
b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 953351f896c3..c8a13d733c98 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -378,7 +378,8 @@ static signed int recvframe_chkmic(struct adapter *adapter, 
 union recv_frame *p
 
} else {
/* mic checked ok */
-   if ((psecuritypriv->bcheck_grpkey == false) && 
(IS_MCAST(prxattrib->ra) == true))
+   if ((psecuritypriv->bcheck_grpkey == false) &&
+   (IS_MCAST(prxattrib->ra) == true))
psecuritypriv->bcheck_grpkey = true;
}
}
-- 
2.20.1



[PATCH v2 23/30] staging: rtl8723bs: fix comparison in if condition

2021-04-02 Thread Fabio Aiuto
fix post-commit checkpatch issue:

CHECK: Using comparison to false is error prone
27: FILE: drivers/staging/rtl8723bs/core/rtw_recv.c:381:
+   if (psecuritypriv->
bcheck_grpkey == false &&

Signed-off-by: Fabio Aiuto 
---
 drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c 
b/drivers/staging/rtl8723bs/core/rtw_recv.c
index cd4324a93275..21949925ec77 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -378,7 +378,7 @@ static signed int recvframe_chkmic(struct adapter *adapter, 
 union recv_frame *p
 
} else {
/* mic checked ok */
-   if (psecuritypriv->bcheck_grpkey == false &&
+   if (!psecuritypriv->bcheck_grpkey &&
(IS_MCAST(prxattrib->ra) == true))
psecuritypriv->bcheck_grpkey = true;
}
-- 
2.20.1



[PATCH v2 20/30] staging: rtl8723bs: added spaces around operator

2021-04-02 Thread Fabio Aiuto
fix post-commit hook issue:

CHECK: spaces preferred around that '+' (ctx:VxV)
60: FILE: drivers/staging/rtl8723bs/core/rtw_recv.c:359:
+   if (miccode[i] != *(pframemic+i))
 ^

Signed-off-by: Fabio Aiuto 
---
 drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c 
b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 2d749341d47b..953351f896c3 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -356,7 +356,7 @@ static signed int recvframe_chkmic(struct adapter *adapter, 
 union recv_frame *p
bmic_err = false;
 
for (i = 0; i < 8; i++) {
-   if (miccode[i] != *(pframemic+i))
+   if (miccode[i] != *(pframemic + i))
bmic_err = true;
}
 
-- 
2.20.1



[PATCH v2 19/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_recv.c

2021-04-02 Thread Fabio Aiuto
remove all RT_TRACE logs

Signed-off-by: Fabio Aiuto 
---
 drivers/staging/rtl8723bs/core/rtw_recv.c | 134 +-
 1 file changed, 6 insertions(+), 128 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c 
b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 189f686a1f29..2d749341d47b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -325,10 +325,6 @@ static signed int recvframe_chkmic(struct adapter 
*adapter,  union recv_frame *p
stainfo = rtw_get_stainfo(>stapriv, >ta[0]);
 
if (prxattrib->encrypt == _TKIP_) {
-   RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n 
recvframe_chkmic:prxattrib->encrypt == _TKIP_\n"));
-   RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n 
recvframe_chkmic:da = 0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n",
-   prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2], 
prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5]));
-
/* calculate mic code */
if (stainfo) {
if (IS_MCAST(prxattrib->ra)) {
@@ -337,28 +333,22 @@ static signed int recvframe_chkmic(struct adapter 
*adapter,  union recv_frame *p
/* rxdata_key_idx =(((iv[3])>>6)&0x3) ; */
mickey = 
>dot118021XGrprxmickey[prxattrib->key_index].skey[0];
 
-   RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, 
("\n recvframe_chkmic: bcmc key\n"));
/* DBG_871X("\n recvframe_chkmic: bcmc key 
psecuritypriv->dot118021XGrpKeyid(%d), pmlmeinfo->key_index(%d) , recv 
key_id(%d)\n", */
/* psecuritypriv->dot118021XGrpKeyid, 
pmlmeinfo->key_index, rxdata_key_idx); */
 
if (psecuritypriv->binstallGrpkey == false) {
res = _FAIL;
-   RT_TRACE(_module_rtl871x_recv_c_, 
_drv_err_, ("\n recvframe_chkmic:didn't install group key!!\n"));
DBG_871X("\n recvframe_chkmic:didn't 
install group key!!\n");
goto exit;
}
} else {
mickey = >dot11tkiprxmickey.skey[0];
-   RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, 
("\n recvframe_chkmic: unicast key\n"));
}
 
datalen = 
precvframe->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len-prxattrib->icv_len-8;/*
 icv_len included the mic code */
pframe = precvframe->u.hdr.rx_data;
payload = pframe+prxattrib->hdrlen+prxattrib->iv_len;
 
-   RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n 
prxattrib->iv_len =%d prxattrib->icv_len =%d\n", prxattrib->iv_len, 
prxattrib->icv_len));
-
-
rtw_seccalctkipmic(mickey, pframe, payload, datalen, 
[0], (unsigned char)prxattrib->priority); /* care the length of the 
data */
 
pframemic = payload+datalen;
@@ -366,38 +356,12 @@ static signed int recvframe_chkmic(struct adapter 
*adapter,  union recv_frame *p
bmic_err = false;
 
for (i = 0; i < 8; i++) {
-   if (miccode[i] != *(pframemic+i)) {
-   RT_TRACE(_module_rtl871x_recv_c_, 
_drv_err_, ("recvframe_chkmic:miccode[%d](%02x) != *(pframemic+%d)(%02x) ", i, 
miccode[i], i, *(pframemic+i)));
+   if (miccode[i] != *(pframemic+i))
bmic_err = true;
-   }
}
 
 
if (bmic_err == true) {
-
-   RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, 
("\n *(pframemic-8)-*(pframemic-1) = 
0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n",
-   *(pframemic-8), *(pframemic-7), 
*(pframemic-6), *(pframemic-5), *(pframemic-4), *(pframemic-3), *(pframemic-2), 
*(pframemic-1)));
-   RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, 
("\n *(pframemic-16)-*(pframemic-9) = 
0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n",
-   *(pframemic-16), *(pframemic-15), 
*(pframemic-14), *(pframemic-13), *(pframemic-12), *(pframemic-11), 
*(pframemic-10), *(pframemic-9)));
-
-   {
-   uint i;
-   RT_TRACE(_module_rtl871x_recv_c_, 
_drv_err_, ("\n ==demp packet (len =%d) ==\n", precvframe->u.hdr.len));
-   for (i = 0; i < precvframe->u.hdr.len; 
i = i+8) {
-   

[PATCH v2 18/30] staging: rtl8723bs: remove commented RT_TRACE calls in core/rtw_recv.c

2021-04-02 Thread Fabio Aiuto
remove commented RT_TRACE calls in core/rtw_recv.c

Signed-off-by: Fabio Aiuto 
---
 drivers/staging/rtl8723bs/core/rtw_recv.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c 
b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 608a59286505..189f686a1f29 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -588,13 +588,11 @@ static union recv_frame *portctrl(struct adapter 
*adapter, union recv_frame *pre
prtnframe = precv_frame;
/* check is the EAPOL frame or not (Rekey) */
/* if (ether_type == eapol_type) { */
-   /* RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, 
("portctrl:ether_type == 0x888e\n")); */
/* check Rekey */
 
/* prtnframe =precv_frame; */
/*  */
/* else { */
-   /* RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, 
("portctrl:ether_type = 0x%04x\n", ether_type)); */
/*  */
}
} else
@@ -1693,7 +1691,6 @@ static signed int validate_recv_frame(struct adapter 
*adapter, union recv_frame
retval = validate_recv_data_frame(adapter, precv_frame);
if (retval == _FAIL) {
struct recv_priv *precvpriv = >recvpriv;
-   /* RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, 
("validate_recv_data_frame fail\n")); */
precvpriv->rx_drop++;
} else if (retval == _SUCCESS) {
 #ifdef DBG_RX_DUMP_EAP
@@ -1889,7 +1886,6 @@ static int check_indicate_seq(struct recv_reorder_ctrl 
*preorder_ctrl, u16 seq_n
 
/*  Drop out the packet which SeqNum is smaller than WinStart */
if (SN_LESS(seq_num, preorder_ctrl->indicate_seq)) {
-   /* RT_TRACE(COMP_RX_REORDER, DBG_LOUD, 
("CheckRxTsIndicateSeq(): Packet Drop! IndicateSeq: %d, NewSeq: %d\n", 
pTS->RxIndicateSeq, NewSeqNum)); */
/* DbgPrint("CheckRxTsIndicateSeq(): Packet Drop! IndicateSeq: 
%d, NewSeq: %d\n", precvpriv->indicate_seq, seq_num); */
 
#ifdef DBG_RX_DROP_FRAME
@@ -1914,7 +1910,6 @@ static int check_indicate_seq(struct recv_reorder_ctrl 
*preorder_ctrl, u16 seq_n
preorder_ctrl->indicate_seq, seq_num);
#endif
} else if (SN_LESS(wend, seq_num)) {
-   /* RT_TRACE(COMP_RX_REORDER, DBG_LOUD, 
("CheckRxTsIndicateSeq(): Window Shift! IndicateSeq: %d, NewSeq: %d\n", 
pTS->RxIndicateSeq, NewSeqNum)); */
/* DbgPrint("CheckRxTsIndicateSeq(): Window Shift! IndicateSeq: 
%d, NewSeq: %d\n", precvpriv->indicate_seq, seq_num); */
 
/*  boundary situation, when seq_num cross 0xFFF */
@@ -1959,7 +1954,6 @@ static int enqueue_reorder_recvframe(struct 
recv_reorder_ctrl *preorder_ctrl, un
plist = get_next(plist);
else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num))
/* Duplicate entry is found!! Do not insert current 
entry. */
-   /* RT_TRACE(COMP_RX_REORDER, DBG_TRACE, 
("InsertRxReorderList(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: 
%d\n", pTS->RxIndicateSeq, SeqNum)); */
/* 
spin_unlock_irqrestore(_recvframe_queue->lock, irql); */
return false;
else
@@ -1980,8 +1974,6 @@ static int enqueue_reorder_recvframe(struct 
recv_reorder_ctrl *preorder_ctrl, un
/* spin_unlock(_recvframe_queue->lock); */
/* spin_unlock_irqrestore(_recvframe_queue->lock, irql); */
 
-
-   /* RT_TRACE(COMP_RX_REORDER, DBG_TRACE, ("InsertRxReorderList(): Pkt 
insert into buffer!! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, 
SeqNum)); */
return true;
 
 }
@@ -2437,8 +2429,6 @@ s32 rtw_recv_entry(union recv_frame *precvframe)
struct recv_priv *precvpriv;
s32 ret = _SUCCESS;
 
-   /* RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, 
("+rtw_recv_entry\n")); */
-
padapter = precvframe->u.hdr.adapter;
 
precvpriv = >recvpriv;
@@ -2456,8 +2446,6 @@ s32 rtw_recv_entry(union recv_frame *precvframe)
 
 _recv_entry_drop:
 
-   /* RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, 
("_recv_entry_drop\n")); */
-
return ret;
 }
 
-- 
2.20.1



[PATCH v2 17/30] staging: rtl8723bs: remove RT_TRACE logs in core/rtw_mlme_ext.c

2021-04-02 Thread Fabio Aiuto
remove all RT_TRACE logs

Signed-off-by: Fabio Aiuto 
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 39 +++
 1 file changed, 5 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 8aadcf72a7ba..9855a77a5188 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -526,14 +526,8 @@ void mgt_dispatcher(struct adapter *padapter, union 
recv_frame *precv_frame)
struct dvobj_priv *psdpriv = padapter->dvobj;
struct debug_priv *pdbgpriv = >drv_dbg;
 
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-("+mgt_dispatcher: type(0x%x) subtype(0x%x)\n",
- GetFrameType(pframe), GetFrameSubType(pframe)));
-
-   if (GetFrameType(pframe) != WIFI_MGT_TYPE) {
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("mgt_dispatcher: 
type(0x%x) error!\n", GetFrameType(pframe)));
+   if (GetFrameType(pframe) != WIFI_MGT_TYPE)
return;
-   }
 
/* receive the frames that ra(a1) is my address or ra(a1) is bc 
address. */
if (memcmp(GetAddr1Ptr(pframe), myid(>eeprompriv), ETH_ALEN) 
&&
@@ -545,10 +539,9 @@ void mgt_dispatcher(struct adapter *padapter, union 
recv_frame *precv_frame)
 
index = GetFrameSubType(pframe) >> 4;
 
-   if (index >= ARRAY_SIZE(mlme_sta_tbl)) {
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Currently we do 
not support reserved sub-fr-type =%d\n", index));
+   if (index >= ARRAY_SIZE(mlme_sta_tbl))
return;
-   }
+
ptable += index;
 
if (psta) {
@@ -2675,8 +2668,6 @@ static int _issue_probereq(struct adapter *padapter,
int bssrate_len = 0;
u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+issue_probereq\n"));
-
pmgntframe = alloc_mgtxmitframe(pxmitpriv);
if (!pmgntframe)
goto exit;
@@ -2743,8 +2734,6 @@ static int _issue_probereq(struct adapter *padapter,
 
pattrib->last_txcmdsz = pattrib->pktlen;
 
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("issuing probe_req, 
tx_len =%d\n", pattrib->last_txcmdsz));
-
if (wait_ack) {
ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe);
} else {
@@ -4441,8 +4430,6 @@ void start_create_ibss(struct adapter *padapter)
 
/* issue beacon */
if (send_beacon(padapter) == _FAIL) {
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("issuing 
beacon frame fail\n"));
-
report_join_res(padapter, -1);
pmlmeinfo->state = WIFI_FW_NULL_STATE;
} else {
@@ -4622,8 +4609,6 @@ static void process_80211d(struct adapter *padapter, 
struct wlan_bssid_ex *bssid
memset(country, 0, 4);
memcpy(country, p, 3);
p += 3;
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
-   ("%s: 802.11d country =%s\n", __func__, 
country));
 
i = 0;
while ((ie - p) >= 3) {
@@ -4813,9 +4798,6 @@ static void process_80211d(struct adapter *padapter, 
struct wlan_bssid_ex *bssid
break;
 
chplan_new[i].ScanType = SCAN_ACTIVE;
-   RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
-("%s: change channel %d scan 
type from passive to active\n",
- __func__, channel));
}
break;
}
@@ -6332,10 +6314,6 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char 
*pbuf)
#ifdef CHECK_EVENT_SEQ
/*  checking event sequence... */
if (evt_seq != (atomic_read(_priv->event_seq) & 0x7f)) {
-   RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
-("Event Seq Error! %d vs %d\n", (evt_seq & 0x7f),
- (atomic_read(_priv->event_seq) & 0x7f)));
-
pevt_priv->event_seq = (evt_seq+1)&0x7f;
 
goto _abort_event_;
@@ -6343,21 +6321,14 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char 
*pbuf)
#endif
 
/*  checking if event code is valid */
-   if (evt_code >= MAX_C2HEVT) {
-   RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nEvent Code(%d) 
mismatch!\n", evt_code));
+   if (evt_code >= MAX_C2HEVT)
goto _abort_event_;
-   }
 
/*  checking if event size match the event parm size */
if ((wlanevents[evt_code].parmsize != 0) &&
-   (wlanevents[evt_code].parmsize != evt_sz)) {
-
-   RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nEvent(%d) Parm 
Size 

<    1   2   3   4   5   6   7   8   9   >