[PATCH v11 0/3] AX88796C SPI Ethernet Adapter

2021-01-25 Thread Łukasz Stelmach
This is a driver for AX88796C Ethernet Adapter connected in SPI mode as
found on ARTIK5 evaluation board. The driver has been ported from a
v3.10.9 vendor kernel for ARTIK5 board.

Changes in v11:
  - changed stat counters to 64-bit
  - replaced WARN_ON(!mutex_is_locked()) with lockdep_assert_held()
  - replaced ax88796c_free_skb_queue() with __skb_queue_purge()
  - added cancel_work_sync() for ax_work
  - removed unused fields of struct skb_data
  - replaced MAX() with max() from minmax.h

Changes in v10:
  - removed unused variable
 
Changes in v9:
  - used pskb_extend_head()
  - used ethtool private flags instead of tunables to switch SPI
compression
  - changed
- alloc_skb() to netdev_alloc(skb)
- __pskb_trim() to pskb_trim()
  - removed:
- chages to skb->truesize
- unnecessary casting to short
- return f() in a void function
- IRQF_SHARED flags
- unnecessary memset(0) of kzalloc()ed buffer
- unused endiannes detection
- unnecessary __packed attribute for some structures
  - added:
- temporary variable in AX_WRITE/READ sequences
- missin mutex_unlock() in error paths
  - axspi_read_reg() returns a constant value in case of an error
  
Changes in v8:
  - fixed the entry in MAINTAINERS
  - removed unnecessary netif_err()
  - changed netif_rx() to netif_rx_ni() for code running in a process
context
  - added explicit type casting for ~BIT()

Changes in v7:
  - removed duplicate code
  - moved a constant buffer definition away from a header file

Changes in v6:
  - fixed typos in Kconfig
  - checked argument value in ax88796c_set_tunable
  - updated tags in commit messages

Changes in v5:
  - coding style (local variable declarations)
  - added spi0 node in the DT binding example and removed
interrupt-parent
  - removed comp module parameter
  - added CONFIG_SPI_AX88796C_COMPRESSION option to set the initial
state of SPI compression
  - introduced new ethtool tunable "spi-compression" to controll SPI
transfer compression
  - removed unused fields in struct ax88796c_device
  - switched from using buffers allocated on stack for SPI transfers
to DMA safe ones embedded in struct ax_spi and allocated with
kmalloc()

Changes in v4:
  - fixed compilation problems in asix,ax88796c.yaml and in
  ax88796c_main.c introduced in v3

Changes in v3:
  - modify vendor-prefixes.yaml in a separate patch
  - fix several problems in the dt binding
- removed unnecessary descriptions and properties
- changed the order of entries
- fixed problems with missing defines in the example
  - change (1 << N) to BIT(N), left a few (0 << N)
  - replace ax88796c_get_link(), ax88796c_get_link_ksettings(),
ax88796c_set_link_ksettings(), ax88796c_nway_reset(),
ax88796c_set_mac_address() with appropriate kernel functions.
  - disable PHY auto-polling in MAC and use PHYLIB to track the state
of PHY and configure MAC
  - propagate return values instead of returning constants in several
places
  - add WARN_ON() for unlocked mutex
  - remove local work queue and use the system_wq
  - replace phy_connect_direct() with phy_connect() and move
devm_register_netdev() to the end of ax88796c_probe()
(Unlike phy_connect_direct() phy_connect() does not crash if the
network device isn't registered yet.)
  - remove error messages on ENOMEM
  - move free_irq() to the end of ax88796c_close() to avoid race
condition
  - implement flow-control

Changes in v2:
  - use phylib
  - added DT bindings
  - moved #includes to *.c files
  - used mutex instead of a semaphore for locking
  - renamed some constants
  - added error propagation for several functions
  - used ethtool for dumping registers
  - added control over checksum offloading
  - remove vendor specific PM
  - removed macaddr module parameter and added support for reading a MAC
address from platform data (e.g. DT)
  - removed dependency on SPI from NET_VENDOR_ASIX
  - added an entry in the MAINTAINERS file
  - simplified logging with appropriate netif_* and netdev_* helpers
  - lots of style fixes

Łukasz Stelmach (3):
  dt-bindings: vendor-prefixes: Add asix prefix
  dt-bindings: net: Add bindings for AX88796C SPI Ethernet Adapter
  net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver

 .../bindings/net/asix,ax88796c.yaml   |   73 ++
 .../devicetree/bindings/vendor-prefixes.yaml  |2 +
 MAINTAINERS   |6 +
 drivers/net/ethernet/Kconfig  |1 +
 drivers/net/ethernet/Makefile |1 +
 drivers/net/ethernet/asix/Kconfig |   35 +
 drivers/net/ethernet/asix/Makefile|6 +
 drivers/net/ethernet/asix/ax88796c_ioctl.c|  239 
 drivers/net/ethernet/asix/ax88796c_ioctl.h|   26 +
 drivers/net/ethernet/asix/ax88796c_main.c | 1146 +
 drivers/net/ethernet/asix/ax88796c_main.h |  568 
 drivers/net/ethernet/asix/ax88796c_spi.c  |  115 ++
 

Re: [PATCH] KVM: x86/mmu: improve robustness of some functions

2021-01-25 Thread Sean Christopherson
On Mon, Jan 25, 2021, Paolo Bonzini wrote:
> On 25/01/21 10:54, Vitaly Kuznetsov wrote:
> > 
> > What if we do something like (completely untested):
> > 
> > diff --git a/arch/x86/kvm/mmu/mmu_internal.h 
> > b/arch/x86/kvm/mmu/mmu_internal.h
> > index bfc6389edc28..5ec15e4160b1 100644
> > --- a/arch/x86/kvm/mmu/mmu_internal.h
> > +++ b/arch/x86/kvm/mmu/mmu_internal.h
> > @@ -12,7 +12,7 @@
> >  extern bool dbg;
> >  #define pgprintk(x...) do { if (dbg) printk(x); } while (0)
> > -#define rmap_printk(x...) do { if (dbg) printk(x); } while (0)
> > +#define rmap_printk(fmt, args...) do { if (dbg) printk("%s: " fmt, 
> > __func__, ## args); } while (0)
> >  #define MMU_WARN_ON(x) WARN_ON(x)
> >  #else
> >  #define pgprintk(x...) do { } while (0)
> > 
> > and eliminate the need to pass '__func__,' explicitly? We can probably
> > do the same to pgprintk().
> 
> Nice indeed.  Though I wonder if anybody has ever used these.

I've used the ones in pte_list_add() and __pte_list_remove().  I had to add more
info to track down the bug I introduced, but their initial existence was 
helpful.

That being said, I definitely did not build with MMU_DEBUG defined, I simply
changed a handful of rmap_printks to pr_warn.  Blindly enabling MMU_DEBUG
activates far too much output to be useful.  That may not have been the case
when the core parts of the MMU were under heavy development, but it does feel
like the time has come to excise the bulk of the pgprintk and rmap_printk hooks.
Ditto for mmu_audit.c.

> For those that I actually needed in the past I created tracepoints instead.

Ya.  There are times where I prefer using the kernel log over tracepoints, but
it's easy enough to copy-paste the tracepoint into a pr_* when desired.

I'd be ok with converting a few select rmap_printks to tracepoints, but I vote
to completely remove the bulk of the existing code.  Tracepoints always make me
a bit wary, it's easy to forget/overlook that the inputs to the tracepoint are
still generated even if the tracepoint itself is disabled.  E.g. being too
liberal with tracepoints could theoretically degrade performance.

If we do yank them, I think it makes sense to git rid of mmu_audit.c in the same
commit.  In theory, that would make it easier for someone to restore the hooks
if they need the hooks to debug something in the future.


Re: [PATCH] PCI: dwc: layerscape: convert to builtin_platform_driver()

2021-01-25 Thread Lorenzo Pieralisi
On Wed, Jan 20, 2021 at 08:28:36PM +0100, Michael Walle wrote:
> [RESEND, fat-fingered the buttons of my mail client and converted
> all CCs to BCCs :(]
> 
> Am 2021-01-20 20:02, schrieb Saravana Kannan:
> > On Wed, Jan 20, 2021 at 6:24 AM Rob Herring  wrote:
> > > 
> > > On Wed, Jan 20, 2021 at 4:53 AM Michael Walle 
> > > wrote:
> > > >
> > > > fw_devlink will defer the probe until all suppliers are ready. We can't
> > > > use builtin_platform_driver_probe() because it doesn't retry after probe
> > > > deferral. Convert it to builtin_platform_driver().
> > > 
> > > If builtin_platform_driver_probe() doesn't work with fw_devlink, then
> > > shouldn't it be fixed or removed?
> > 
> > I was actually thinking about this too. The problem with fixing
> > builtin_platform_driver_probe() to behave like
> > builtin_platform_driver() is that these probe functions could be
> > marked with __init. But there are also only 20 instances of
> > builtin_platform_driver_probe() in the kernel:
> > $ git grep ^builtin_platform_driver_probe | wc -l
> > 20
> > 
> > So it might be easier to just fix them to not use
> > builtin_platform_driver_probe().
> > 
> > Michael,
> > 
> > Any chance you'd be willing to help me by converting all these to
> > builtin_platform_driver() and delete builtin_platform_driver_probe()?
> 
> If it just moving the probe function to the _driver struct and
> remove the __init annotations. I could look into that.

Can I drop this patch then ?

Thanks,
Lorenzo


[PATCH net-next 1/3] mm: constify page_is_pfmemalloc() argument

2021-01-25 Thread Alexander Lobakin
The function only tests for page->index, so its argument should be
const.

Signed-off-by: Alexander Lobakin 
---
 include/linux/mm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index ecdf8a8cd6ae..078633d43af9 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1584,7 +1584,7 @@ struct address_space *page_mapping_file(struct page 
*page);
  * ALLOC_NO_WATERMARKS and the low watermark was not
  * met implying that the system is under some pressure.
  */
-static inline bool page_is_pfmemalloc(struct page *page)
+static inline bool page_is_pfmemalloc(const struct page *page)
 {
/*
 * Page index cannot be this large so this must be
-- 
2.30.0




[PATCH net-next 0/3] net: constify page_is_pfmemalloc() and its users

2021-01-25 Thread Alexander Lobakin
page_is_pfmemalloc() is used mostly by networking drivers. It doesn't
write anything to the struct page itself, so constify its argument and
a bunch of callers and wrappers around this function in drivers.
In Page Pool core code, it can be simply inlined instead.

Alexander Lobakin (3):
  mm: constify page_is_pfmemalloc() argument
  net: constify page_is_pfmemalloc() argument at call sites
  net: page_pool: simplify page recycling condition tests

 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c   |  2 +-
 drivers/net/ethernet/intel/fm10k/fm10k_main.c |  2 +-
 drivers/net/ethernet/intel/i40e/i40e_txrx.c   |  2 +-
 drivers/net/ethernet/intel/iavf/iavf_txrx.c   |  2 +-
 drivers/net/ethernet/intel/ice/ice_txrx.c |  2 +-
 drivers/net/ethernet/intel/igb/igb_main.c |  2 +-
 drivers/net/ethernet/intel/igc/igc_main.c |  2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |  2 +-
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c |  2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c   |  2 +-
 include/linux/mm.h|  2 +-
 include/linux/skbuff.h|  4 ++--
 net/core/page_pool.c  | 14 --
 13 files changed, 17 insertions(+), 23 deletions(-)

-- 
2.30.0




[PATCH] net: phy: remove h from printk format specifier

2021-01-25 Thread trix
From: Tom Rix 

This change fixes the checkpatch warning described in this commit
commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of
  unnecessary %h[xudi] and %hh[xudi]")

Standard integer promotion is already done and %hx and %hhx is useless
so do not encourage the use of %hh[xudi] or %h[xudi].

Signed-off-by: Tom Rix 
---
 drivers/net/phy/dp83640.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 0d79f68f301c..1bc68a3bffa2 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -186,7 +186,7 @@ static void dp83640_gpio_defaults(struct ptp_pin_desc *pd)
 
for (i = 0; i < GPIO_TABLE_SIZE; i++) {
if (gpio_tab[i] < 1 || gpio_tab[i] > DP83640_N_PINS) {
-   pr_err("gpio_tab[%d]=%hu out of range", i, gpio_tab[i]);
+   pr_err("gpio_tab[%d]=%u out of range", i, gpio_tab[i]);
return;
}
}
-- 
2.27.0



Re: [PATCH v3 2/6] ALSA: hda/tegra: Reset hardware

2021-01-25 Thread Takashi Iwai
On Wed, 20 Jan 2021 01:31:50 +0100,
Dmitry Osipenko wrote:
> 
> Reset hardware on RPM-resume in order to bring it into a predictable
> state.
> 
> Tested-by: Peter Geis  # Ouya T30 audio works
> Tested-by: Matt Merhar  # Ouya T30 boot-tested
> Tested-by: Nicolas Chauvet  # TK1 boot-tested
> Signed-off-by: Dmitry Osipenko 

Currently we have neither dependency nor reverse-selection of
CONFIG_RESET_CONTROLLER.  It wouldn't be a problem for builds, but
you'll get a runtime error from
devm_reset_control_array_get_exclusive() always when
CONFIG_RESET_CONTROLLER=n.

I guess it must be a corner case, but just to be sure.


thanks,

Takashi


> ---
>  sound/pci/hda/hda_tegra.c | 20 
>  1 file changed, 20 insertions(+)
> 
> diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c
> index a25bf7083c28..04dcd4cdfd9e 100644
> --- a/sound/pci/hda/hda_tegra.c
> +++ b/sound/pci/hda/hda_tegra.c
> @@ -17,6 +17,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -70,6 +71,7 @@
>  struct hda_tegra {
>   struct azx chip;
>   struct device *dev;
> + struct reset_control *reset;
>   struct clk_bulk_data clocks[3];
>   unsigned int nclocks;
>   void __iomem *regs;
> @@ -167,6 +169,12 @@ static int __maybe_unused 
> hda_tegra_runtime_resume(struct device *dev)
>   struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip);
>   int rc;
>  
> + if (!chip->running) {
> + rc = reset_control_assert(hda->reset);
> + if (rc)
> + return rc;
> + }
> +
>   rc = clk_bulk_prepare_enable(hda->nclocks, hda->clocks);
>   if (rc != 0)
>   return rc;
> @@ -176,6 +184,12 @@ static int __maybe_unused 
> hda_tegra_runtime_resume(struct device *dev)
>   /* disable controller wake up event*/
>   azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) &
>  ~STATESTS_INT_MASK);
> + } else {
> + usleep_range(10, 100);
> +
> + rc = reset_control_deassert(hda->reset);
> + if (rc)
> + return rc;
>   }
>  
>   return 0;
> @@ -441,6 +455,12 @@ static int hda_tegra_probe(struct platform_device *pdev)
>   return err;
>   }
>  
> + hda->reset = devm_reset_control_array_get_exclusive(>dev);
> + if (IS_ERR(hda->reset)) {
> + err = PTR_ERR(hda->reset);
> + goto out_free;
> + }
> +
>   hda->clocks[hda->nclocks++].id = "hda";
>   hda->clocks[hda->nclocks++].id = "hda2hdmi";
>   hda->clocks[hda->nclocks++].id = "hda2codec_2x";
> -- 
> 2.29.2
> 


Re: [PATCH v3 0/3] Some optimization for stage-2 translation

2021-01-25 Thread Marc Zyngier
On Thu, 14 Jan 2021 20:13:47 +0800, Yanan Wang wrote:
> This patch series(v3) make some optimization for stage-2 translation.
> 
> About patch-1:
> Procedures of hyp stage-1 map and guest stage-2 map are quite different,
> but they are now tied closely by function kvm_set_valid_leaf_pte().
> So adjust the relative code for ease of code maintenance in the future.
> 
> [...]

Applied to kvm-arm64/concurrent-translation-fault, thanks!

[1/3] KVM: arm64: Adjust partial code of hyp stage-1 map and guest stage-2 map
  commit: 8ed80051c8c31d1587722fdb3af16677eba9d693
[2/3] KVM: arm64: Filter out the case of only changing permissions from stage-2 
map path
  commit: 694d071f8d85d504055540a27f0dbe9dbf44584e
[3/3] KVM: arm64: Mark the page dirty only if the fault is handled successfully
  commit: 509552e65ae8287178a5cdea2d734dcd2d6380ab

Cheers,

M.
-- 
Without deviation from the norm, progress is not possible.




[PATCH] usb: dwc3: fix clock issue during resume in OTG mode

2021-01-25 Thread Gary Bisson
Commit fe8abf332b8f ("usb: dwc3: support clocks and resets for DWC3
core") introduced clock support and a new function named
dwc3_core_init_for_resume() which enables the clock before calling
dwc3_core_init() during resume as clocks get disabled during suspend.

Unfortunately in this commit the DWC3_GCTL_PRTCAP_OTG case was forgotten
and therefore during resume, a platform could call dwc3_core_init()
without re-enabling the clocks first, preventing to resume properly.

So update the resume path to call dwc3_core_init_for_resume() as it
should.

Fixes: fe8abf332b8f ("usb: dwc3: support clocks and resets for DWC3
core")

Cc: sta...@vger.kernel.org
Signed-off-by: Gary Bisson 
---
 drivers/usb/dwc3/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 841daec70b6e..3101f0dcf6ae 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1758,7 +1758,7 @@ static int dwc3_resume_common(struct dwc3 *dwc, 
pm_message_t msg)
if (PMSG_IS_AUTO(msg))
break;
 
-   ret = dwc3_core_init(dwc);
+   ret = dwc3_core_init_for_resume(dwc);
if (ret)
return ret;
 
-- 
2.29.2



Re: [PATCH v3 2/6] drivers: crypto: qce: sha: Hold back a block of data to be transferred as part of final

2021-01-25 Thread Bjorn Andersson
On Wed 20 Jan 12:48 CST 2021, Thara Gopinath wrote:

> If the available data to transfer is exactly a multiple of block size, save
> the last block to be transferred in qce_ahash_final (with the last block
> bit set) if this is indeed the end of data stream. If not this saved block
> will be transferred as part of next update. If this block is not held back
> and if this is indeed the end of data stream, the digest obtained will be
> wrong since qce_ahash_final will see that rctx->buflen is 0 and return
> doing nothing which in turn means that a digest will not be copied to the
> destination result buffer.  qce_ahash_final cannot be made to alter this
> behavior and allowed to proceed if rctx->buflen is 0 because the crypto
> engine BAM does not allow for zero length transfers.
> 

Please drop "drivers: " from $subject.

Apart from that this looks good.

Reviewed-by: Bjorn Andersson 

Regards,
Bjorn

> Signed-off-by: Thara Gopinath 
> ---
>  drivers/crypto/qce/sha.c | 19 +++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c
> index 08aed03e2b59..dd263c5e4dd8 100644
> --- a/drivers/crypto/qce/sha.c
> +++ b/drivers/crypto/qce/sha.c
> @@ -216,6 +216,25 @@ static int qce_ahash_update(struct ahash_request *req)
>  
>   /* calculate how many bytes will be hashed later */
>   hash_later = total % blocksize;
> +
> + /*
> +  * At this point, there is more than one block size of data.  If
> +  * the available data to transfer is exactly a multiple of block
> +  * size, save the last block to be transferred in qce_ahash_final
> +  * (with the last block bit set) if this is indeed the end of data
> +  * stream. If not this saved block will be transferred as part of
> +  * next update. If this block is not held back and if this is
> +  * indeed the end of data stream, the digest obtained will be wrong
> +  * since qce_ahash_final will see that rctx->buflen is 0 and return
> +  * doing nothing which in turn means that a digest will not be
> +  * copied to the destination result buffer.  qce_ahash_final cannot
> +  * be made to alter this behavior and allowed to proceed if
> +  * rctx->buflen is 0 because the crypto engine BAM does not allow
> +  * for zero length transfers.
> +  */
> + if (!hash_later)
> + hash_later = blocksize;
> +
>   if (hash_later) {
>   unsigned int src_offset = req->nbytes - hash_later;
>   scatterwalk_map_and_copy(rctx->buf, req->src, src_offset,
> -- 
> 2.25.1
> 


Re: [PATCH v2] kdb: Simplify kdb commands registration

2021-01-25 Thread Doug Anderson
Hi,

On Sun, Jan 24, 2021 at 11:06 PM Sumit Garg  wrote:
>
> Simplify kdb commands registration via using linked list instead of
> static array for commands storage.
>
> Signed-off-by: Sumit Garg 
> ---
>
> Changes in v2:
> - Remove redundant NULL check for "cmd_name".
> - Incorporate misc. comment.
>
>  kernel/debug/kdb/kdb_main.c| 119 
> -
>  kernel/debug/kdb/kdb_private.h |   1 +
>  2 files changed, 34 insertions(+), 86 deletions(-)
>
> diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
> index 930ac1b..a0989a0 100644
> --- a/kernel/debug/kdb/kdb_main.c
> +++ b/kernel/debug/kdb/kdb_main.c
> @@ -33,6 +33,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -84,15 +85,8 @@ static unsigned int kdb_continue_catastrophic =
>  static unsigned int kdb_continue_catastrophic;
>  #endif
>
> -/* kdb_commands describes the available commands. */
> -static kdbtab_t *kdb_commands;
> -#define KDB_BASE_CMD_MAX 50
> -static int kdb_max_commands = KDB_BASE_CMD_MAX;
> -static kdbtab_t kdb_base_commands[KDB_BASE_CMD_MAX];
> -#define for_each_kdbcmd(cmd, num)  \
> -   for ((cmd) = kdb_base_commands, (num) = 0;  \
> -num < kdb_max_commands;\
> -num++, num == KDB_BASE_CMD_MAX ? cmd = kdb_commands : cmd++)
> +/* kdb_cmds_head describes the available commands. */
> +static LIST_HEAD(kdb_cmds_head);
>
>  typedef struct _kdbmsg {
> int km_diag;/* kdb diagnostic */
> @@ -921,7 +915,7 @@ int kdb_parse(const char *cmdstr)
> char *cp;
> char *cpp, quoted;
> kdbtab_t *tp;
> -   int i, escaped, ignore_errors = 0, check_grep = 0;
> +   int escaped, ignore_errors = 0, check_grep = 0;
>
> /*
>  * First tokenize the command string.
> @@ -1011,25 +1005,18 @@ int kdb_parse(const char *cmdstr)
> ++argv[0];
> }
>
> -   for_each_kdbcmd(tp, i) {
> -   if (tp->cmd_name) {
> -   /*
> -* If this command is allowed to be abbreviated,
> -* check to see if this is it.
> -*/
> -
> -   if (tp->cmd_minlen
> -&& (strlen(argv[0]) <= tp->cmd_minlen)) {
> -   if (strncmp(argv[0],
> -   tp->cmd_name,
> -   tp->cmd_minlen) == 0) {
> -   break;
> -   }
> -   }
> -
> -   if (strcmp(argv[0], tp->cmd_name) == 0)
> +   list_for_each_entry(tp, _cmds_head, list_node) {
> +   /*
> +* If this command is allowed to be abbreviated,
> +* check to see if this is it.
> +*/
> +   if (tp->cmd_minlen && (strlen(argv[0]) <= tp->cmd_minlen)) {
> +   if (strncmp(argv[0], tp->cmd_name, tp->cmd_minlen) == 
> 0)
> break;
> }

The old code had the same problem, but since you're touching it you could fix?

if (a) {
  if (b)
break;
}

...is the same as:

if (a && b)
  break;

In any case, this looks like quite a nice cleanup, so:

Reviewed-by: Douglas Anderson 


[PATCH v3] tracing: precise log info for kretprobe addr err

2021-01-25 Thread Jianlin Lv
When trying to create kretprobe with the wrong function symbol in tracefs;
The error is triggered in the register_trace_kprobe() and recorded as
FAIL_REG_PROBE issue,

Example:
  $ cd /sys/kernel/debug/tracing
  $ echo 'r:myprobe ERROR_SYMBOL_XXX ret=%x0' >> kprobe_events
bash: echo: write error: Invalid argument
  $ cat error_log
[142797.347877] trace_kprobe: error: Failed to register probe event
Command: r:myprobe ERROR_SYMBOL_XXX ret=%x0
   ^

This error can be detected in the parameter parsing stage, the effect of
applying this patch is as follows:

  $ echo 'r:myprobe ERROR_SYMBOL_XXX ret=%x0' >> kprobe_events
bash: echo: write error: Invalid argument
  $ cat error_log
[415.89]trace_kprobe: error: Retprobe address must be an function entry
Command: r:myprobe ERROR_SYMBOL_XXX ret=%x0
   ^

Signed-off-by: Jianlin Lv 
---
v2:add !strchr(symbol, ':') to check really bad symbol or not.
---
 kernel/trace/trace_kprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index e6fba1798771..bce63d5ecaec 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -830,7 +830,7 @@ static int trace_kprobe_create(int argc, const char *argv[])
flags |= TPARG_FL_RETURN;
if (kprobe_on_func_entry(NULL, symbol, offset))
flags |= TPARG_FL_FENTRY;
-   if (offset && is_return && !(flags & TPARG_FL_FENTRY)) {
+   if (!strchr(symbol, ':') && is_return && !(flags & 
TPARG_FL_FENTRY)) {
trace_probe_log_err(0, BAD_RETPROBE);
goto parse_error;
}
-- 
2.25.1



Re: [PATCH 11/13] devfreq: tegra30: Migrate to dev_pm_opp_set_opp()

2021-01-25 Thread Dmitry Osipenko
25.01.2021 06:14, Viresh Kumar пишет:
> On 22-01-21, 18:28, Dmitry Osipenko wrote:
>> Either way will work, but maybe keeping the dev_pm_opp_set_bw() is a bit
>> more straightforward variant for now since it will avoid the code's
>> changes and it's probably a bit more obvious variant for the OPP users.
> 
> The problem is it creates unnecessary paths which we need to support. For
> example, in case of bandwidth itself we may want to update regulator/pm
> domain/required OPPs and this should all be done for everyone. I really do not
> want to keep separate paths for such stuff, it makes it hard to maintain..
> 

Maybe we could add dev_pm_opp_of_add_table_without_clock(), at least
that should be a bit nicer from a drivers perspective than having to
care about dev_pm_opp_clear_clk(), IMO.


Re: [PATCH 3/4] ARM: dts: qcom: msm8974-klte: add support for display

2021-01-25 Thread Bjorn Andersson
On Mon 25 Jan 09:47 CST 2021, Konrad Dybcio wrote:

> 
> > I know how bad it is, so I understand your desire to not have to rebase
> > that, but I will merge things as they become ready on the list.
> >
> > So please post your change (perhaps it's posted and I'm failing to find
> > it in my inbox?) and I'd be happy to merge it so we get it cleaned up!
> >
> > Thanks,
> > Bjorn
> 
> 
> Here it is: [1]
> 
> 
> Be aware that it truly is humongous and should be split (I couldn't
> resist adding missing pins/dma while cleaning things up) and it.. was
> not really intended to be sent as-is. It's also supposed to work on
> the previous release of Linux, so some Samsung DTs in particular
> changed since and will need some manual rebasing. But I'll happily
> leave it as a reference if somebody has the time to pick it up. The
> konrad/8974 branch in this repo contains more (beware, GPU ones are
> untested!) 8974 fixes and I have some more on my drive that are.. not
> really ready for their prime time just yet either..
> 

I like the end result, so please spend some time trying to get this
upstream (which would save you from having to rebase that going forward
:))

As you say I don't think it's appropriate to post or merge it as is, but
you should be able to send patches related to the 7 steps described in
the commit message - and don't be afraid of splitting it in more than
those patches. And we don't need to merge them all at once either...

Regards,
Bjorn


Re: [PATCH] net/bluetooth: Fix the follow coccicheck warnings

2021-01-25 Thread Marcel Holtmann
Hi Jiapeng,

> ./net/bluetooth/hci_debugfs.c: WARNING: sniff_min_interval_fops
> should be defined with DEFINE_DEBUGFS_ATTRIBUTE
> 
> Signed-off-by: Jiapeng Zhong 
> Reported-by: Abaci Robot
> ---
> net/bluetooth/hci_debugfs.c | 38 +++---
> 1 file changed, 19 insertions(+), 19 deletions(-)
> 
> diff --git a/net/bluetooth/hci_debugfs.c b/net/bluetooth/hci_debugfs.c
> index 4626e02..65cad9f 100644
> --- a/net/bluetooth/hci_debugfs.c
> +++ b/net/bluetooth/hci_debugfs.c
> @@ -237,7 +237,7 @@ static int conn_info_min_age_get(void *data, u64 *val)
>   return 0;
> }
> 
> -DEFINE_SIMPLE_ATTRIBUTE(conn_info_min_age_fops, conn_info_min_age_get,
> +DEFINE_DEBUGFS_ATTRIBUTE(conn_info_min_age_fops, conn_info_min_age_get,
>   conn_info_min_age_set, "%llu\n");

while I am fine with the patch, put please make sure the indentation alignment 
of the second line is also correct.

Regards

Marcel



Re: [PATCH 3/4] ARM: dts: qcom: msm8974-klte: add support for display

2021-01-25 Thread Konrad Dybcio


> I know how bad it is, so I understand your desire to not have to rebase
> that, but I will merge things as they become ready on the list.
>
> So please post your change (perhaps it's posted and I'm failing to find
> it in my inbox?) and I'd be happy to merge it so we get it cleaned up!
>
> Thanks,
> Bjorn


Here it is: [1]


Be aware that it truly is humongous and should be split (I couldn't resist 
adding missing pins/dma while cleaning things up) and it.. was not really 
intended to be sent as-is. It's also supposed to work on the previous release 
of Linux, so some Samsung DTs in particular changed since and will need some 
manual rebasing. But I'll happily leave it as a reference if somebody has the 
time to pick it up. The konrad/8974 branch in this repo contains more (beware, 
GPU ones are untested!) 8974 fixes and I have some more on my drive that are.. 
not really ready for their prime time just yet either..


Konrad



[1] 
https://github.com/SoMainline/linux/commit/291ea6860f8b95df67d63fbd378d61b3a157ac15



Re: [PATCH 1/3] KVM: SVM: Unconditionally sync GPRs to GHCB on VMRUN of SEV-ES guest

2021-01-25 Thread Tom Lendacky
On 1/22/21 5:50 PM, Sean Christopherson wrote:
> Drop the per-GPR dirty checks when synchronizing GPRs to the GHCB, the
> GRPs' dirty bits are set from time zero and never cleared, i.e. will

Ah, missed that, bad assumption on my part.

> always be seen as dirty.  The obvious alternative would be to clear
> the dirty bits when appropriate, but removing the dirty checks is
> desirable as it allows reverting GPR dirty+available tracking, which
> adds overhead to all flavors of x86 VMs.
> 
> Note, unconditionally writing the GPRs in the GHCB is tacitly allowed
> by the GHCB spec, which allows the hypervisor (or guest) to provide
> unnecessary info; it's the guest's responsibility to consume only what
> it needs (the hypervisor is untrusted after all).
> 
>   The guest and hypervisor can supply additional state if desired but
>   must not rely on that additional state being provided.

Yes, that's true.

I'm ok with removing the tracking if that's desired. Otherwise, we can add
a vcpu->arch.regs_dirty = 0 in sev_es_sync_from_ghcb().

Thanks,
Tom

> 
> Cc: Brijesh Singh 
> Cc: Tom Lendacky 
> Fixes: 291bd20d5d88 ("KVM: SVM: Add initial support for a VMGEXIT VMEXIT")
> Signed-off-by: Sean Christopherson 
> ---
>  arch/x86/kvm/svm/sev.c | 15 ++-
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index c8ffdbc81709..ac652bc476ae 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -1415,16 +1415,13 @@ static void sev_es_sync_to_ghcb(struct vcpu_svm *svm)
>* to be returned:
>*   GPRs RAX, RBX, RCX, RDX
>*
> -  * Copy their values to the GHCB if they are dirty.
> +  * Copy their values, even if they may not have been written during the
> +  * VM-Exit.  It's the guest's responsibility to not consume random data.
>*/
> - if (kvm_register_is_dirty(vcpu, VCPU_REGS_RAX))
> - ghcb_set_rax(ghcb, vcpu->arch.regs[VCPU_REGS_RAX]);
> - if (kvm_register_is_dirty(vcpu, VCPU_REGS_RBX))
> - ghcb_set_rbx(ghcb, vcpu->arch.regs[VCPU_REGS_RBX]);
> - if (kvm_register_is_dirty(vcpu, VCPU_REGS_RCX))
> - ghcb_set_rcx(ghcb, vcpu->arch.regs[VCPU_REGS_RCX]);
> - if (kvm_register_is_dirty(vcpu, VCPU_REGS_RDX))
> - ghcb_set_rdx(ghcb, vcpu->arch.regs[VCPU_REGS_RDX]);
> + ghcb_set_rax(ghcb, vcpu->arch.regs[VCPU_REGS_RAX]);
> + ghcb_set_rbx(ghcb, vcpu->arch.regs[VCPU_REGS_RBX]);
> + ghcb_set_rcx(ghcb, vcpu->arch.regs[VCPU_REGS_RCX]);
> + ghcb_set_rdx(ghcb, vcpu->arch.regs[VCPU_REGS_RDX]);
>  }
>  
>  static void sev_es_sync_from_ghcb(struct vcpu_svm *svm)
> 


Re: [PATCH] [net-next] ipa: add remoteproc dependency

2021-01-25 Thread Arnd Bergmann
On Mon, Jan 25, 2021 at 4:23 PM Bjorn Andersson
 wrote:
>
> On Mon 25 Jan 05:35 CST 2021, Arnd Bergmann wrote:
>
> > From: Arnd Bergmann 
> >
> > Compile-testing without CONFIG_REMOTEPROC results in a build failure:
> >
> > >>> referenced by ipa_main.c
> > >>>   net/ipa/ipa_main.o:(ipa_probe) in archive 
> > >>> drivers/built-in.a
> > ld.lld: error: undefined symbol: rproc_put
> > >>> referenced by ipa_main.c
> > >>>   net/ipa/ipa_main.o:(ipa_probe) in archive 
> > >>> drivers/built-in.a
> > >>> referenced by ipa_main.c
> > >>>   net/ipa/ipa_main.o:(ipa_remove) in archive 
> > >>> drivers/built-in.a
> >
> > Add a new dependency to avoid this.
> >
>
> Afaict this should be addressed by:
>
> 86fdf1fc60e9 ("net: ipa: remove a remoteproc dependency")
>
> which is present in linux-next.

Ok, good. I was testing with next-20210122, which was
still lacking that commit.

  Arnd


Re: [PATCH v3] Bluetooth: btrtl: Enable WBS for the specific Realtek devices

2021-01-25 Thread Marcel Holtmann
Hi Max,

> By this change, it will enable WBS supported on the specific Realtek BT
> devices, such as RTL8822C and RTL8852A.
> In the future, it's able to maintain what the Realtek devices support WBS
> here.
> 
> Tested-by: Hilda Wu 
> Reviewed-by: Abhishek Pandit-Subedi 
> Signed-off-by: Max Chou 
> 
> ---
> change in v3
> -remove the null check due to unnecessary
> ---
> drivers/bluetooth/btrtl.c | 29 +++--
> 1 file changed, 23 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
> index 24f03a1f8d57..a21d6abc93c4 100644
> --- a/drivers/bluetooth/btrtl.c
> +++ b/drivers/bluetooth/btrtl.c
> @@ -38,6 +38,19 @@
>   .hci_ver = (hciv), \
>   .hci_bus = (bus)
> 
> +enum  btrtl_chip_id {

remove the extra space here.

> + CHIP_ID_8723A,  /* index  0 for RTL8723A*/
> + CHIP_ID_8723B,  /* index  1 for RTL8723B*/
> + CHIP_ID_8821A,  /* index  2 for RTL8821A*/
> + CHIP_ID_8761A,  /* index  3 for RTL8761A*/
> + CHIP_ID_8822B = 8,  /* index  8 for RTL8822B */
> + CHIP_ID_8723D,  /* index  9 for RTL8723D */
> + CHIP_ID_8821C,  /* index 10 for RTL8821C */
> + CHIP_ID_8822C = 13, /* index 13 for RTL8822C */
> + CHIP_ID_8761B,  /* index 14 for RTL8761B */
> + CHIP_ID_8852A = 18, /* index 18 for RTL8852A */
> +};
> +
> struct id_table {
>   __u16 match_flags;
>   __u16 lmp_subver;
> @@ -58,6 +71,7 @@ struct btrtl_device_info {
>   u8 *cfg_data;
>   int cfg_len;
>   bool drop_fw;
> + int project_id;
> };
> 
> static const struct id_table ic_id_table[] = {
> @@ -307,8 +321,10 @@ static int rtlbt_parse_firmware(struct hci_dev *hdev,
> 
>   /* Find project_id in table */
>   for (i = 0; i < ARRAY_SIZE(project_id_to_lmp_subver); i++) {
> - if (project_id == project_id_to_lmp_subver[i].id)
> + if (project_id == project_id_to_lmp_subver[i].id) {
> + btrtl_dev->project_id = project_id;
>   break;
> + }
>   }
> 
>   if (i >= ARRAY_SIZE(project_id_to_lmp_subver)) {
> @@ -719,18 +735,19 @@ int btrtl_setup_realtek(struct hci_dev *hdev)
>*/
>   set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, >quirks);
> 
> - if (!btrtl_dev->ic_info)
> - goto done;
> -
>   /* Enable central-peripheral role (able to create new connections with
>* an existing connection in slave role).
>*/
> - switch (btrtl_dev->ic_info->lmp_subver) {
> - case RTL_ROM_LMP_8822B:
> + /* Enable WBS supported for the specific Realtek devices. */
> + switch (btrtl_dev->project_id) {
> + case CHIP_ID_8822C:
> + case CHIP_ID_8852A:
>   set_bit(HCI_QUIRK_VALID_LE_STATES, >quirks);
> + set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, >quirks);
>   break;
>   default:
>   rtl_dev_dbg(hdev, "Central-peripheral role not enabled.");
> + rtl_dev_dbg(hdev, "WBS supported not enabled.");
>   break;
>   }

Regards

Marcel



Re: [PATCH v3] Bluetooth: Keep MSFT ext info throughout ahci_dev's life cycle

2021-01-25 Thread Marcel Holtmann
Hi Miao-chen,

> This moves msft_do_close() from hci_dev_do_close() to
> hci_unregister_dev() to avoid clearing MSFT extension info. This also
> avoids retrieving MSFT info upon every msft_do_open() if MSFT extension
> has been initialized.
> 
> The following test steps were performed.
> (1) boot the test device and verify the MSFT support debug log in syslog
> (2) restart bluetoothd and verify msft_do_close() doesn't get invoked
> 
> Signed-off-by: Miao-chen Chou 
> Reviewed-by: Abhishek Pandit-Subedi 
> Reviewed-by: Archie Pusaka 
> ---
> Hi Maintainers,
> 
> This patch fixes the life cycle of MSFT HCI extension. The current
> symmetric calls to msft_do{open,close} in hci_dev_do_{open,close} cause
> incorrect MSFT features during bluetoothd start-up. After the kernel
> powers on the controller to register the hci_dev, it performs
> hci_dev_do_close() which call msft_do_close() and MSFT data gets wiped
> out. And then during the startup of bluetoothd, Adv Monitor Manager
> relies on reading the MSFT features from the kernel to present the
> feature set of the controller to D-Bus clients. However, the power state
> of the controller is off during the init of D-Bus interfaces. As a
> result, invalid MSFT features are returned by the kernel, since it was
> previously wiped out due to hci_dev_do_close().

then just keep the values around and not wipe them. However I prefer still to 
keep the symmetry and re-read the value every time we init. We can make sure to 
release the msft_data on unregister.

Regards

Marcel



Re: [PATCH v2 0/5] Introduce PRU remoteproc consumer API

2021-01-25 Thread Suman Anna
Hi Santosh,

On 1/24/21 10:34 PM, santosh.shilim...@oracle.com wrote:
> Hi Suman, Mathieu,
> 
> On 1/7/21 2:49 PM, Suman Anna wrote:
>> On 1/7/21 4:44 PM, Mathieu Poirier wrote:
>>> On Wed, Jan 06, 2021 at 06:03:25PM -0600, Suman Anna wrote:
 Hi Mathieu,

> [...]
>>> I only see input from Andy and Lars in the thread you point out, nothing 
>>> from
>>> Greg.  I have also taken a look at the patch [1] that made checkpatch 
>>> complain
>>> about ENOTSUPP.  From what I see in that commit log the goal is to prevent 
>>> new
>>> additions of ENOTSUPP to the kernel.
>>>
>>> Please modify and resend, otherwise I'm sure someone will send another 
>>> patch to
>>> fix it before the end of the cycle.
>>
>> Yeah ok. I will send out a v3.
>>
> I haven't seen v3 of this series yet. Please post it
> if you would like to include it for 5.12.

This series is dependent on couple of patches that would have to come through
the remoteproc tree first, and I need to post the next versions of those as
well. So, let me sort out those first. You can drop this from your queue for 
5.12.

regards
Suman


Re: linux-next: Signed-off-by missing for commit in the block tree

2021-01-25 Thread Jens Axboe
On 1/25/21 2:43 AM, Stephen Rothwell wrote:
> Hi all,
> 
> Commits
> 
>   36962a1e4186 ("io_uring: create common fixed_rsrc_data allocation routines")
>   5bc97865b3b6 ("io_uring: create common fixed_rsrc_ref_node handling 
> routines")
>   b2315a2cda1f ("io_uring: generalize io_queue_rsrc_removal")
>   a63c1259317d ("io_uring: rename file related variables to rsrc")
> 
> are missing a Signed-off-by from their author.

Fixed up, thanks.

-- 
Jens Axboe



Re: [PATCH 1/2] media: venus: core: Add sdm660 DT compatible and resource struct

2021-01-25 Thread Bjorn Andersson
On Mon 25 Jan 08:51 CST 2021, AngeloGioacchino Del Regno wrote:

> Il 25/01/21 11:40, Hans Verkuil ha scritto:
> > On 18/01/2021 18:45, AngeloGioacchino Del Regno wrote:
> > > Il 18/01/21 18:21, Stanimir Varbanov ha scritto:
> > > > > diff --git a/drivers/media/platform/qcom/venus/core.c 
> > > > > b/drivers/media/platform/qcom/venus/core.c
[..]
> > > > > + .fwname = "qcom/venus-4.4/venus.mdt",
[..]
> > This patch can't be merged unless there is a corresponding firmware 
> > available
> > in linux-firmware. Is the current 4.2 firmware in linux-firmware signed by
> > Qualcomm? Can they provided 4.4 firmware as well?
> > 
> 
> If there is such issue, then maybe we should do "something" about it: I
> would then propose to remove all references to fwname and just get this
> done in DT, where every qcom board already specifies its own path for
> its own firmware.
> 

We have the same problem with production devices on e.g. SDM845, where
the firmware referenced by fw_name and present in linux-firmware won't
work on any real devices.

As such, providing means for specifying the firmware name in DT would be
a very reasonable thing, and in line with how we handle this in other
subsystems (using the firmware-name property, containing the full
relative path).

Regards,
Bjorn


Re: [PATCH][next] drm/amdgpu: Fix masking binary not operator on two mask operations

2021-01-25 Thread Alex Deucher
Applied.  Thanks!

Alex

On Sun, Jan 24, 2021 at 11:36 PM Huang Rui  wrote:
>
> On Fri, Jan 22, 2021 at 11:00:22PM +0800, Colin King wrote:
> > From: Colin Ian King 
> >
> > Currently the ! operator is incorrectly being used to flip bits on
> > mask values. Fix this by using the bit-wise ~ operator instead.
> >
> > Addresses-Coverity: ("Logical vs. bitwise operator")
> > Fixes: 3c9a7b7d6e75 ("drm/amdgpu: update mmhub mgcg for mmhub_v2_3")
> > Signed-off-by: Colin Ian King 
>
> Thanks.
>
> Reviewed-by: Huang Rui 
>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c 
> > b/drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c
> > index 1961745e89c7..ab9be5ad5a5f 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c
> > @@ -531,12 +531,12 @@ mmhub_v2_3_update_medium_grain_light_sleep(struct 
> > amdgpu_device *adev,
> >
> >   if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_LS)) {
> >   data &= ~MM_ATC_L2_CGTT_CLK_CTRL__MGLS_OVERRIDE_MASK;
> > - data1 &= !(DAGB0_WR_CGTT_CLK_CTRL__LS_OVERRIDE_MASK |
> > + data1 &= ~(DAGB0_WR_CGTT_CLK_CTRL__LS_OVERRIDE_MASK |
> >   DAGB0_WR_CGTT_CLK_CTRL__LS_OVERRIDE_WRITE_MASK |
> >   DAGB0_WR_CGTT_CLK_CTRL__LS_OVERRIDE_READ_MASK |
> >   DAGB0_WR_CGTT_CLK_CTRL__LS_OVERRIDE_RETURN_MASK |
> >   DAGB0_WR_CGTT_CLK_CTRL__LS_OVERRIDE_REGISTER_MASK);
> > - data2 &= !(DAGB0_RD_CGTT_CLK_CTRL__LS_OVERRIDE_MASK |
> > + data2 &= ~(DAGB0_RD_CGTT_CLK_CTRL__LS_OVERRIDE_MASK |
> >   DAGB0_RD_CGTT_CLK_CTRL__LS_OVERRIDE_WRITE_MASK |
> >   DAGB0_RD_CGTT_CLK_CTRL__LS_OVERRIDE_READ_MASK |
> >   DAGB0_RD_CGTT_CLK_CTRL__LS_OVERRIDE_RETURN_MASK |
> > --
> > 2.29.2
> >
> ___
> amd-gfx mailing list
> amd-...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH] [net-next] ipa: add remoteproc dependency

2021-01-25 Thread Alex Elder

On 1/25/21 9:30 AM, Arnd Bergmann wrote:

On Mon, Jan 25, 2021 at 4:23 PM Bjorn Andersson
 wrote:


On Mon 25 Jan 05:35 CST 2021, Arnd Bergmann wrote:


From: Arnd Bergmann 

Compile-testing without CONFIG_REMOTEPROC results in a build failure:


referenced by ipa_main.c
   net/ipa/ipa_main.o:(ipa_probe) in archive drivers/built-in.a

ld.lld: error: undefined symbol: rproc_put

referenced by ipa_main.c
   net/ipa/ipa_main.o:(ipa_probe) in archive drivers/built-in.a
referenced by ipa_main.c
   net/ipa/ipa_main.o:(ipa_remove) in archive drivers/built-in.a


Add a new dependency to avoid this.



Afaict this should be addressed by:

86fdf1fc60e9 ("net: ipa: remove a remoteproc dependency")

which is present in linux-next.


Ok, good. I was testing with next-20210122, which was
still lacking that commit.


Yes, for various reasons this took a while to get incorporated.
It just got accepted over the weekend.  Thanks for mentioning it.

-Alex



   Arnd





Re: [PATCH 4/4] vfio-pci/zdev: Introduce the zPCI I/O vfio region

2021-01-25 Thread Cornelia Huck
On Mon, 25 Jan 2021 09:40:38 -0500
Matthew Rosato  wrote:

> On 1/22/21 6:48 PM, Alex Williamson wrote:
> > On Tue, 19 Jan 2021 15:02:30 -0500
> > Matthew Rosato  wrote:
> >   
> >> Some s390 PCI devices (e.g. ISM) perform I/O operations that have very
> >> specific requirements in terms of alignment as well as the patterns in
> >> which the data is read/written. Allowing these to proceed through the
> >> typical vfio_pci_bar_rw path will cause them to be broken in up in such a
> >> way that these requirements can't be guaranteed. In addition, ISM devices
> >> do not support the MIO codepaths that might be triggered on vfio I/O coming
> >> from userspace; we must be able to ensure that these devices use the
> >> non-MIO instructions.  To facilitate this, provide a new vfio region by
> >> which non-MIO instructions can be passed directly to the host kernel s390
> >> PCI layer, to be reliably issued as non-MIO instructions.
> >>
> >> This patch introduces the new vfio VFIO_REGION_SUBTYPE_IBM_ZPCI_IO region
> >> and implements the ability to pass PCISTB and PCILG instructions over it,
> >> as these are what is required for ISM devices.  
> > 
> > There have been various discussions about splitting vfio-pci to allow
> > more device specific drivers rather adding duct tape and bailing wire
> > for various device specific features to extend vfio-pci.  The latest
> > iteration is here[1].  Is it possible that such a solution could simply
> > provide the standard BAR region indexes, but with an implementation that
> > works on s390, rather than creating new device specific regions to
> > perform the same task?  Thanks,
> > 
> > Alex
> > 
> > [1]https://lore.kernel.org/lkml/20210117181534.65724-1-mgurto...@nvidia.com/
> >   
> 
> Thanks for the pointer, I'll have to keep an eye on this.  An approach 
> like this could solve some issues, but I think a main issue that still 
> remains with relying on the standard BAR region indexes (whether using 
> the current vfio-pci driver or a device-specific driver) is that QEMU 
> writes to said BAR memory region are happening in, at most, 8B chunks 
> (which then, in the current general-purpose vfio-pci code get further 
> split up into 4B iowrite operations).  The alternate approach I'm 
> proposing here is allowing for the whole payload (4K) in a single 
> operation, which is significantly faster.  So, I suspect even with a 
> device specific driver we'd want this sort of a region anyhow..

I'm also wondering about device specific vs architecture/platform
specific handling.

If we're trying to support ISM devices, that's device specific
handling; but if we're trying to add more generic things like the large
payload support, that's not necessarily tied to a device, is it? For
example, could a device support large payload if plugged into a z, but
not if plugged into another machine?



[PATCH v2 1/4] dt-bindings: renesas,rcar-dmac: Add r8a779a0 support

2021-01-25 Thread Geert Uytterhoeven
Document the compatible value for the Direct Memory Access Controller
blocks in the Renesas R-Car V3U (R8A779A0) SoC.

The most visible difference with DMAC blocks on other R-Car SoCs is the
move of the per-channel registers to a separate register block.

Signed-off-by: Geert Uytterhoeven 
Reviewed-by: Rob Herring 
---
v2:
  - Add Reviewed-by.
---
 .../bindings/dma/renesas,rcar-dmac.yaml   | 76 ---
 1 file changed, 48 insertions(+), 28 deletions(-)

diff --git a/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml 
b/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml
index c07eb6f2fc8d2f12..7f2a54bc732d3a19 100644
--- a/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml
+++ b/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml
@@ -14,34 +14,37 @@ allOf:
 
 properties:
   compatible:
-items:
-  - enum:
-  - renesas,dmac-r8a7742  # RZ/G1H
-  - renesas,dmac-r8a7743  # RZ/G1M
-  - renesas,dmac-r8a7744  # RZ/G1N
-  - renesas,dmac-r8a7745  # RZ/G1E
-  - renesas,dmac-r8a77470 # RZ/G1C
-  - renesas,dmac-r8a774a1 # RZ/G2M
-  - renesas,dmac-r8a774b1 # RZ/G2N
-  - renesas,dmac-r8a774c0 # RZ/G2E
-  - renesas,dmac-r8a774e1 # RZ/G2H
-  - renesas,dmac-r8a7790  # R-Car H2
-  - renesas,dmac-r8a7791  # R-Car M2-W
-  - renesas,dmac-r8a7792  # R-Car V2H
-  - renesas,dmac-r8a7793  # R-Car M2-N
-  - renesas,dmac-r8a7794  # R-Car E2
-  - renesas,dmac-r8a7795  # R-Car H3
-  - renesas,dmac-r8a7796  # R-Car M3-W
-  - renesas,dmac-r8a77961 # R-Car M3-W+
-  - renesas,dmac-r8a77965 # R-Car M3-N
-  - renesas,dmac-r8a77970 # R-Car V3M
-  - renesas,dmac-r8a77980 # R-Car V3H
-  - renesas,dmac-r8a77990 # R-Car E3
-  - renesas,dmac-r8a77995 # R-Car D3
-  - const: renesas,rcar-dmac
-
-  reg:
-maxItems: 1
+oneOf:
+  - items:
+  - enum:
+  - renesas,dmac-r8a7742  # RZ/G1H
+  - renesas,dmac-r8a7743  # RZ/G1M
+  - renesas,dmac-r8a7744  # RZ/G1N
+  - renesas,dmac-r8a7745  # RZ/G1E
+  - renesas,dmac-r8a77470 # RZ/G1C
+  - renesas,dmac-r8a774a1 # RZ/G2M
+  - renesas,dmac-r8a774b1 # RZ/G2N
+  - renesas,dmac-r8a774c0 # RZ/G2E
+  - renesas,dmac-r8a774e1 # RZ/G2H
+  - renesas,dmac-r8a7790  # R-Car H2
+  - renesas,dmac-r8a7791  # R-Car M2-W
+  - renesas,dmac-r8a7792  # R-Car V2H
+  - renesas,dmac-r8a7793  # R-Car M2-N
+  - renesas,dmac-r8a7794  # R-Car E2
+  - renesas,dmac-r8a7795  # R-Car H3
+  - renesas,dmac-r8a7796  # R-Car M3-W
+  - renesas,dmac-r8a77961 # R-Car M3-W+
+  - renesas,dmac-r8a77965 # R-Car M3-N
+  - renesas,dmac-r8a77970 # R-Car V3M
+  - renesas,dmac-r8a77980 # R-Car V3H
+  - renesas,dmac-r8a77990 # R-Car E3
+  - renesas,dmac-r8a77995 # R-Car D3
+  - const: renesas,rcar-dmac
+
+  - items:
+  - const: renesas,dmac-r8a779a0 # R-Car V3U
+
+  reg: true
 
   interrupts:
 minItems: 9
@@ -110,6 +113,23 @@ required:
   - power-domains
   - resets
 
+if:
+  properties:
+compatible:
+  contains:
+enum:
+  - renesas,dmac-r8a779a0
+then:
+  properties:
+reg:
+  items:
+- description: Base register block
+- description: Channel register block
+else:
+  properties:
+reg:
+  maxItems: 1
+
 additionalProperties: false
 
 examples:
-- 
2.25.1



[PATCH v2 3/4] dmaengine: rcar-dmac: Add helpers for clearing DMA channel status

2021-01-25 Thread Geert Uytterhoeven
Extract the code to clear the status of one or all channels into their
own helpers, to prepare for the different handling of the R-Car V3U SoC.

Signed-off-by: Geert Uytterhoeven 
---
v2:
  - No changes.
---
 drivers/dma/sh/rcar-dmac.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 537550b4121bbc22..7a0f802c61e5152d 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -336,6 +336,17 @@ static void rcar_dmac_chan_write(struct rcar_dmac_chan 
*chan, u32 reg, u32 data)
writel(data, chan->iomem + reg);
 }
 
+static void rcar_dmac_chan_clear(struct rcar_dmac *dmac,
+struct rcar_dmac_chan *chan)
+{
+   rcar_dmac_write(dmac, RCAR_DMACHCLR, BIT(chan->index));
+}
+
+static void rcar_dmac_chan_clear_all(struct rcar_dmac *dmac)
+{
+   rcar_dmac_write(dmac, RCAR_DMACHCLR, dmac->channels_mask);
+}
+
 /* 
-
  * Initialization and configuration
  */
@@ -451,7 +462,7 @@ static int rcar_dmac_init(struct rcar_dmac *dmac)
u16 dmaor;
 
/* Clear all channels and enable the DMAC globally. */
-   rcar_dmac_write(dmac, RCAR_DMACHCLR, dmac->channels_mask);
+   rcar_dmac_chan_clear_all(dmac);
rcar_dmac_write(dmac, RCAR_DMAOR,
RCAR_DMAOR_PRI_FIXED | RCAR_DMAOR_DME);
 
@@ -1566,7 +1577,7 @@ static irqreturn_t rcar_dmac_isr_channel(int irq, void 
*dev)
 * because channel is already stopped in error case.
 * We need to clear register and check DE bit as recovery.
 */
-   rcar_dmac_write(dmac, RCAR_DMACHCLR, 1 << chan->index);
+   rcar_dmac_chan_clear(dmac, chan);
rcar_dmac_chcr_de_barrier(chan);
reinit = true;
goto spin_lock_end;
-- 
2.25.1



[PATCH v4 00/21] arm64: sunxi: Initial Allwinner H616 SoC support

2021-01-25 Thread Andre Przywara
Hi,

an update from the v3 last week, to add support for the Allwinner H616
SoC. Still based on the (updated) sunxi/for-next branch.
I am omitting the MMC and pinctrl patches now, as they have been taken
by Ulf and LinusW already into their trees.

I addressed the comments from the list, though not sure if the HOSC clock
coming from the RTC is really a good idea (didn't change it).

I was hoping that at least the clock and AXP patches (01/21-06/21) could
make it into 5.12 still? That would allow booting boards from SD card.
I am happy to strip the .dtsi and .dts patch to only contain the devices
that we actually support then, if needed.

For the changes: I split the joint DT bindings patch into subsystem
specific ones, hopefully this simplifies merging. There is a new fix
for the axp20x-pek driver, and the AXP IRQ fix has been amended as well
(according to Samuel's comments).

I eventually got USB to work, by requiring PHY 2 for [EO]HCI 1 & 3 as well.
Not sure this is the right fix, it might be just one clock or reset
line from that PHY that is needed for the others as well. Will do further
experiments.

For a more detailed changelog, see below.

Thanks!
Andre

==
This series gathers patches to support the Allwinner H616 SoC. This is
a rather uninspired SoC (Quad-A53 with the usual peripherals), but
allows for some cheap development boards and TV boxes, and supports
up to 4GB of DRAM.

Various DT binding patches are sprinkled throughout the series, to add
the new compatible names right before they are used.
Patch 2 and 3 add clock support. For the -R clock this is shared with
the H6 code, as the clocks are identical, with the H616 just having
fewer of them. The main clocks are different enough to warrant a separate
file.
Patches 5 and 6 teach the AXP MFD driver to get along without having an
interrupt, as the missing NMI pin on the H616 leads to some boards not
having the AXP IRQ line connected.
Patch 8 and 14 add some tweaks to the syscon and EMAC driver, to deal
with the second EMAC clock used for the second Ethernet controller.
Patches 15 and 18 add USB support.

The remaining patches add DT bindings, which just add the new compatible
string along with an existing name as a fallback string.
Eventually we get the .dtsi for the SoC in patch 19, and the .dts for
the OrangePi Zero2 board[1] in the last patch.

We have U-Boot and Trusted-Firmware support in a working state, booting
via FEL or SD card and even TFTPing kernels work already [2][3].
The U-Boot patches are going to be merged this week.

Many thanks to Jernej for his tremendous help on this, also for the
awesome input and help from the #linux-sunxi Freenode channel.

The whole series (including the other patches) can also be found here:
https://github.com/apritzel/linux/commits/h616-v4

Happy reviewing!

Cheers,
Andre

[1] https://linux-sunxi.org/Xunlong_Orange_Pi_Zero2
[2] https://github.com/jernejsk/u-boot/commits/h616-v2
[3] https://github.com/apritzel/arm-trusted-firmware/commits/h616-v1

Changelog v3 .. v4:
- Drop MMC and pinctrl matches (already in some -next trees)
- Add Maxime's Acks
- Add patch to update the AXP MFD DT bindings
- Add new patch (05/21) to fix axp20x-pek driver
- Change AXP IRQ fix to check for invalid IRQ line number
- Split joint DT bindings patch (v3 18/21) into subsystems
- move dwmac variable to keep christmas tree
- Use enums for USB PHY compatible strings in DT binding
- Enable watchdog (briefly verified to work)
- Add PHY2 to HCI1&3, this fixes USB
- limit r-ccu register frame length to not collide with NMI controller
- add interrupt-controller property to AXP DT node

Changelog v2 .. v3:
- Add Rob's Acks
- Drop redundant maxItems from pinctrl DT binding
- Rename h_i2s* to just i2s* in pinctrl names
- Use more declarative i2s0_d{in,out}{0,1} names
- Add RSB pins to pinctrl
- Include RSB clocks (sharing with newly added H6 versions)
- Fix CEC clock (add 2nd enable bit, also fix predivider flag)
- Rename PMU_UNK1 register in USB PHY
- Add USB and MUSB DT binding patches
- Add MMC/SD speed modes to .dtsi

Changelog v1 .. v2:
- pinctrl: adjust irq bank map to cover undocumented GPIO bank IRQs
- use differing h_i2s0 pin output names
- r-ccu: fix number of used clocks
- ccu: remove PLL-PERIPHy(4X)
- ccu: fix gpu1 divider range
- ccu: fix usb-phy3 parent
- ccu: add missing TV clocks
- ccu: rework to CLK_OF_DECLARE style
- ccu: enable output bit for PLL clocks
- ccu: renumber clocks
- .dtsi: drop sun50i-a64-system-control fallback
- .dtsi: drop unknown SRAM regions
- .dtsi: add more (undocumented) GPIO interrupts
- .dtsi: fix I2C3 pin names
- .dtsi: use a100-emmc fallback for MMC2
- .dtsi: add second EMAC controller
- .dtsi: use H3 MUSB controller fallback
- .dtsi: fix frame size for USB PHY PMU registers
- .dtsi: add USB0 PHY references
- .dtsi: fix IR controller clock source
- .dts: fix LED naming and swap pins
- .dts: use 5V supply parent for USB supply
- .dts: drop dummy IRQ for AXP
- .dts: enable 3V3 

Re: [PATCH 3/4] ARM: dts: qcom: msm8974-klte: add support for display

2021-01-25 Thread Bjorn Andersson
On Sun 24 Jan 11:33 CST 2021, Konrad Dybcio wrote:

> 
> > All msm8974 dts(i) files use this style. Deviating from it for this doesn't 
> > make sense. And yes msm8974 should probably be converted to the newer label 
> > style (as was done with msm8916 a while ago).
> 
> I have a >3k lines commit fixing that. Adding more code that strays
> from the new style doesn't really help.
> 

I know how bad it is, so I understand your desire to not have to rebase
that, but I will merge things as they become ready on the list.

So please post your change (perhaps it's posted and I'm failing to find
it in my inbox?) and I'd be happy to merge it so we get it cleaned up!

Thanks,
Bjorn


[PATCH v2 5/7] rbtree, uprobes: Use rbtree helpers

2021-01-25 Thread Peter Zijlstra
Reduce rbtree boilerplate by using the new helpers.

Signed-off-by: Peter Zijlstra (Intel) 
---
 kernel/events/uprobes.c |   82 +++-
 1 file changed, 40 insertions(+), 42 deletions(-)

--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -619,41 +619,56 @@ static void put_uprobe(struct uprobe *up
}
 }
 
-static int match_uprobe(struct uprobe *l, struct uprobe *r)
+static __always_inline
+int uprobe_cmp(const struct inode *l_inode, const loff_t l_offset,
+  const struct uprobe *r)
 {
-   if (l->inode < r->inode)
+   if (l_inode < r->inode)
return -1;
 
-   if (l->inode > r->inode)
+   if (l_inode > r->inode)
return 1;
 
-   if (l->offset < r->offset)
+   if (l_offset < r->offset)
return -1;
 
-   if (l->offset > r->offset)
+   if (l_offset > r->offset)
return 1;
 
return 0;
 }
 
+#define __node_2_uprobe(node) \
+   rb_entry((node), struct uprobe, rb_node)
+
+struct __uprobe_key {
+   struct inode *inode;
+   loff_t offset;
+};
+
+static inline int __uprobe_cmp_key(const void *key, const struct rb_node *b)
+{
+   const struct __uprobe_key *a = key;
+   return uprobe_cmp(a->inode, a->offset, __node_2_uprobe(b));
+}
+
+static inline int __uprobe_cmp(struct rb_node *a, const struct rb_node *b)
+{
+   struct uprobe *u = __node_2_uprobe(a);
+   return uprobe_cmp(u->inode, u->offset, __node_2_uprobe(b));
+}
+
 static struct uprobe *__find_uprobe(struct inode *inode, loff_t offset)
 {
-   struct uprobe u = { .inode = inode, .offset = offset };
-   struct rb_node *n = uprobes_tree.rb_node;
-   struct uprobe *uprobe;
-   int match;
+   struct __uprobe_key key = {
+   .inode = inode,
+   .offset = offset,
+   };
+   struct rb_node *node = rb_find(, _tree, __uprobe_cmp_key);
+
+   if (node)
+   return __node_2_uprobe(node);
 
-   while (n) {
-   uprobe = rb_entry(n, struct uprobe, rb_node);
-   match = match_uprobe(, uprobe);
-   if (!match)
-   return get_uprobe(uprobe);
-
-   if (match < 0)
-   n = n->rb_left;
-   else
-   n = n->rb_right;
-   }
return NULL;
 }
 
@@ -674,32 +689,15 @@ static struct uprobe *find_uprobe(struct
 
 static struct uprobe *__insert_uprobe(struct uprobe *uprobe)
 {
-   struct rb_node **p = _tree.rb_node;
-   struct rb_node *parent = NULL;
-   struct uprobe *u;
-   int match;
-
-   while (*p) {
-   parent = *p;
-   u = rb_entry(parent, struct uprobe, rb_node);
-   match = match_uprobe(uprobe, u);
-   if (!match)
-   return get_uprobe(u);
-
-   if (match < 0)
-   p = >rb_left;
-   else
-   p = >rb_right;
+   struct rb_node *node;
 
-   }
+   node = rb_find_add(>rb_node, _tree, __uprobe_cmp);
+   if (node)
+   return get_uprobe(__node_2_uprobe(node));
 
-   u = NULL;
-   rb_link_node(>rb_node, parent, p);
-   rb_insert_color(>rb_node, _tree);
/* get access + creation ref */
refcount_set(>ref, 2);
-
-   return u;
+   return NULL;
 }
 
 /*




[PATCH v2 1/7] rbtree: Add generic add and find helpers

2021-01-25 Thread Peter Zijlstra
I've always been bothered by the endless (fragile) boilerplate for
rbtree, and I recently wrote some rbtree helpers for objtool and
figured I should lift them into the kernel and use them more widely.

Provide:

partial-order; less() based:
 - rb_add(): add a new entry to the rbtree
 - rb_add_cached(): like rb_add(), but for a rb_root_cached

total-order; cmp() based:
 - rb_find(): find an entry in an rbtree
 - rb_find_add(): find an entry, and add if not found

 - rb_find_first(): find the first (leftmost) matching entry
 - rb_next_match(): continue from rb_find_first()
 - rb_for_each(): iterate a sub-tree using the previous two

Inlining and constant propagation should see the compiler inline the
whole thing, including the various compare functions.

Signed-off-by: Peter Zijlstra (Intel) 
Reviewed-by: Michel Lespinasse 
---
 include/linux/rbtree.h   |  190 ++
 tools/include/linux/rbtree.h |  192 ++-
 tools/objtool/elf.c  |   73 ++--
 3 files changed, 392 insertions(+), 63 deletions(-)

--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -158,4 +158,194 @@ static inline void rb_replace_node_cache
rb_replace_node(victim, new, >rb_root);
 }
 
+/*
+ * The below helper functions use 2 operators with 3 different
+ * calling conventions. The operators are related like:
+ *
+ * comp(a->key,b) < 0  := less(a,b)
+ * comp(a->key,b) > 0  := less(b,a)
+ * comp(a->key,b) == 0 := !less(a,b) && !less(b,a)
+ *
+ * If these operators define a partial order on the elements we make no
+ * guarantee on which of the elements matching the key is found. See
+ * rb_find().
+ *
+ * The reason for this is to allow the find() interface without requiring an
+ * on-stack dummy object, which might not be feasible due to object size.
+ */
+
+/**
+ * rb_add_cached() - insert @node into the leftmost cached tree @tree
+ * @node: node to insert
+ * @tree: leftmost cached tree to insert @node into
+ * @less: operator defining the (partial) node order
+ */
+static __always_inline void
+rb_add_cached(struct rb_node *node, struct rb_root_cached *tree,
+ bool (*less)(struct rb_node *, const struct rb_node *))
+{
+   struct rb_node **link = >rb_root.rb_node;
+   struct rb_node *parent = NULL;
+   bool leftmost = true;
+
+   while (*link) {
+   parent = *link;
+   if (less(node, parent)) {
+   link = >rb_left;
+   } else {
+   link = >rb_right;
+   leftmost = false;
+   }
+   }
+
+   rb_link_node(node, parent, link);
+   rb_insert_color_cached(node, tree, leftmost);
+}
+
+/**
+ * rb_add() - insert @node into @tree
+ * @node: node to insert
+ * @tree: tree to insert @node into
+ * @less: operator defining the (partial) node order
+ */
+static __always_inline void
+rb_add(struct rb_node *node, struct rb_root *tree,
+   bool (*less)(struct rb_node *, const struct rb_node *))
+{
+   struct rb_node **link = >rb_node;
+   struct rb_node *parent = NULL;
+
+   while (*link) {
+   parent = *link;
+   if (less(node, parent))
+   link = >rb_left;
+   else
+   link = >rb_right;
+   }
+
+   rb_link_node(node, parent, link);
+   rb_insert_color(node, tree);
+}
+
+/**
+ * rb_find_add() - find equivalent @node in @tree, or add @node
+ * @node: node to look-for / insert
+ * @tree: tree to search / modify
+ * @cmp: operator defining the node order
+ *
+ * Returns the rb_node matching @node, or NULL when no match is found and @node
+ * is inserted.
+ */
+static __always_inline struct rb_node *
+rb_find_add(struct rb_node *node, struct rb_root *tree,
+   int (*cmp)(struct rb_node *, const struct rb_node *))
+{
+   struct rb_node **link = >rb_node;
+   struct rb_node *parent = NULL;
+   int c;
+
+   while (*link) {
+   parent = *link;
+   c = cmp(node, parent);
+
+   if (c < 0)
+   link = >rb_left;
+   else if (c > 0)
+   link = >rb_right;
+   else
+   return parent;
+   }
+
+   rb_link_node(node, parent, link);
+   rb_insert_color(node, tree);
+   return NULL;
+}
+
+/**
+ * rb_find() - find @key in tree @tree
+ * @key: key to match
+ * @tree: tree to search
+ * @cmp: operator defining the node order
+ *
+ * Returns the rb_node matching @key or NULL.
+ */
+static __always_inline struct rb_node *
+rb_find(const void *key, const struct rb_root *tree,
+   int (*cmp)(const void *key, const struct rb_node *))
+{
+   struct rb_node *node = tree->rb_node;
+
+   while (node) {
+   int c = cmp(key, node);
+
+   if (c < 0)
+   node = node->rb_left;
+   else if (c > 0)
+  

[PATCH RESEND V12 3/8] fuse: Definitions and ioctl for passthrough

2021-01-25 Thread Alessio Balsini
Expose the FUSE_PASSTHROUGH interface to user space and declare all the
basic data structures and functions as the skeleton on top of which the
FUSE passthrough functionality will be built.

As part of this, introduce the new FUSE passthrough ioctl, which allows
the FUSE daemon to specify a direct connection between a FUSE file and a
lower file system file. Such ioctl requires user space to pass the file
descriptor of one of its opened files through the fuse_passthrough_out
data structure introduced in this patch. This structure includes extra
fields for possible future extensions.
Also, add the passthrough functions for the set-up and tear-down of the
data structures and locks that will be used both when fuse_conns and
fuse_files are created/deleted.

Signed-off-by: Alessio Balsini 
---
 fs/fuse/Makefile  |  1 +
 fs/fuse/dev.c | 12 
 fs/fuse/dir.c |  2 ++
 fs/fuse/file.c|  4 +++-
 fs/fuse/fuse_i.h  | 27 +++
 fs/fuse/inode.c   | 17 -
 fs/fuse/passthrough.c | 21 +
 include/uapi/linux/fuse.h | 11 ++-
 8 files changed, 92 insertions(+), 3 deletions(-)
 create mode 100644 fs/fuse/passthrough.c

diff --git a/fs/fuse/Makefile b/fs/fuse/Makefile
index 8c7021fb2cd4..20ed23aa16fa 100644
--- a/fs/fuse/Makefile
+++ b/fs/fuse/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_CUSE) += cuse.o
 obj-$(CONFIG_VIRTIO_FS) += virtiofs.o
 
 fuse-y := dev.o dir.o file.o inode.o control.o xattr.o acl.o readdir.o
+fuse-y += passthrough.o
 fuse-$(CONFIG_FUSE_DAX) += dax.o
 
 virtiofs-y := virtio_fs.o
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index ff9f3b83f879..5446f13db5a0 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -2236,6 +2236,7 @@ static long fuse_dev_ioctl(struct file *file, unsigned 
int cmd,
int res;
int oldfd;
struct fuse_dev *fud = NULL;
+   struct fuse_passthrough_out pto;
 
if (_IOC_TYPE(cmd) != FUSE_DEV_IOC_MAGIC)
return -EINVAL;
@@ -2266,6 +2267,17 @@ static long fuse_dev_ioctl(struct file *file, unsigned 
int cmd,
}
}
break;
+   case _IOC_NR(FUSE_DEV_IOC_PASSTHROUGH_OPEN):
+   res = -EFAULT;
+   if (!copy_from_user(,
+   (struct fuse_passthrough_out __user *)arg,
+   sizeof(pto))) {
+   res = -EINVAL;
+   fud = fuse_get_dev(file);
+   if (fud)
+   res = fuse_passthrough_open(fud, );
+   }
+   break;
default:
res = -ENOTTY;
break;
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 78f9f209078c..c9a1b33c5481 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -513,6 +513,7 @@ static int fuse_create_open(struct inode *dir, struct 
dentry *entry,
 {
int err;
struct inode *inode;
+   struct fuse_conn *fc = get_fuse_conn(dir);
struct fuse_mount *fm = get_fuse_mount(dir);
FUSE_ARGS(args);
struct fuse_forget_link *forget;
@@ -574,6 +575,7 @@ static int fuse_create_open(struct inode *dir, struct 
dentry *entry,
ff->fh = outopen.fh;
ff->nodeid = outentry.nodeid;
ff->open_flags = outopen.open_flags;
+   fuse_passthrough_setup(fc, ff, );
inode = fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation,
  , entry_attr_timeout(), 0);
if (!inode) {
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 8cccecb55fb8..953f3034c375 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -158,7 +158,7 @@ int fuse_do_open(struct fuse_mount *fm, u64 nodeid, struct 
file *file,
if (!err) {
ff->fh = outarg.fh;
ff->open_flags = outarg.open_flags;
-
+   fuse_passthrough_setup(fc, ff, );
} else if (err != -ENOSYS) {
fuse_file_free(ff);
return err;
@@ -304,6 +304,8 @@ void fuse_release_common(struct file *file, bool isdir)
struct fuse_release_args *ra = ff->release_args;
int opcode = isdir ? FUSE_RELEASEDIR : FUSE_RELEASE;
 
+   fuse_passthrough_release(>passthrough);
+
fuse_prepare_release(fi, ff, file->f_flags, opcode);
 
if (ff->flock) {
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 7c4b8cb93f9f..8d39f5304a11 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -180,6 +180,14 @@ struct fuse_conn;
 struct fuse_mount;
 struct fuse_release_args;
 
+/**
+ * Reference to lower filesystem file for read/write operations handled in
+ * passthrough mode
+ */
+struct fuse_passthrough {
+   struct file *filp;
+};
+
 /** FUSE specific file data */
 struct fuse_file {
/** Fuse connection for this file */
@@ -225,6 +233,9 @@ struct fuse_file {
 
} readdir;
 
+ 

[PATCH RESEND V12 4/8] fuse: Passthrough initialization and release

2021-01-25 Thread Alessio Balsini
Implement the FUSE passthrough ioctl that associates the lower
(passthrough) file system file with the fuse_file.

The file descriptor passed to the ioctl by the FUSE daemon is used to
access the relative file pointer, that will be copied to the fuse_file
data structure to consolidate the link between the FUSE and lower file
system.

To enable the passthrough mode, user space triggers the
FUSE_DEV_IOC_PASSTHROUGH_OPEN ioctl and, if the call succeeds, receives
back an identifier that will be used at open/create response time in the
fuse_open_out field to associate the FUSE file to the lower file system
file.
The value returned by the ioctl to user space can be:
- > 0: success, the identifier can be used as part of an open/create
reply.
- <= 0: an error occurred.
The value 0 represents an error to preserve backward compatibility: the
fuse_open_out field that is used to pass the passthrough_fh back to the
kernel uses the same bits that were previously as struct padding, and is
commonly zero-initialized (e.g., in the libfuse implementation).
Removing 0 from the correct values fixes the ambiguity between the case
in which 0 corresponds to a real passthrough_fh, a missing
implementation of FUSE passthrough or a request for a normal FUSE file,
simplifying the user space implementation.

For the passthrough mode to be successfully activated, the lower file
system file must implement both read_iter and write_iter file
operations. This extra check avoids special pseudo files to be targeted
for this feature.
Passthrough comes with another limitation: no further file system
stacking is allowed for those FUSE file systems using passthrough.

Signed-off-by: Alessio Balsini 
---
 fs/fuse/inode.c   |  5 +++
 fs/fuse/passthrough.c | 87 ++-
 2 files changed, 90 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index a1104d5abb70..7ebc398fbacb 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1133,6 +1133,11 @@ EXPORT_SYMBOL_GPL(fuse_send_init);
 
 static int free_fuse_passthrough(int id, void *p, void *data)
 {
+   struct fuse_passthrough *passthrough = (struct fuse_passthrough *)p;
+
+   fuse_passthrough_release(passthrough);
+   kfree(p);
+
return 0;
 }
 
diff --git a/fs/fuse/passthrough.c b/fs/fuse/passthrough.c
index 594060c654f8..cf993e83803e 100644
--- a/fs/fuse/passthrough.c
+++ b/fs/fuse/passthrough.c
@@ -3,19 +3,102 @@
 #include "fuse_i.h"
 
 #include 
+#include 
 
 int fuse_passthrough_open(struct fuse_dev *fud,
  struct fuse_passthrough_out *pto)
 {
-   return -EINVAL;
+   int res;
+   struct file *passthrough_filp;
+   struct fuse_conn *fc = fud->fc;
+   struct inode *passthrough_inode;
+   struct super_block *passthrough_sb;
+   struct fuse_passthrough *passthrough;
+
+   if (!fc->passthrough)
+   return -EPERM;
+
+   /* This field is reserved for future implementation */
+   if (pto->len != 0)
+   return -EINVAL;
+
+   passthrough_filp = fget(pto->fd);
+   if (!passthrough_filp) {
+   pr_err("FUSE: invalid file descriptor for passthrough.\n");
+   return -EBADF;
+   }
+
+   if (!passthrough_filp->f_op->read_iter ||
+   !passthrough_filp->f_op->write_iter) {
+   pr_err("FUSE: passthrough file misses file operations.\n");
+   res = -EBADF;
+   goto err_free_file;
+   }
+
+   passthrough_inode = file_inode(passthrough_filp);
+   passthrough_sb = passthrough_inode->i_sb;
+   if (passthrough_sb->s_stack_depth >= FILESYSTEM_MAX_STACK_DEPTH) {
+   pr_err("FUSE: fs stacking depth exceeded for passthrough\n");
+   res = -EINVAL;
+   goto err_free_file;
+   }
+
+   passthrough = kmalloc(sizeof(struct fuse_passthrough), GFP_KERNEL);
+   if (!passthrough) {
+   res = -ENOMEM;
+   goto err_free_file;
+   }
+
+   passthrough->filp = passthrough_filp;
+
+   idr_preload(GFP_KERNEL);
+   spin_lock(>passthrough_req_lock);
+   res = idr_alloc(>passthrough_req, passthrough, 1, 0, GFP_ATOMIC);
+   spin_unlock(>passthrough_req_lock);
+   idr_preload_end();
+
+   if (res > 0)
+   return res;
+
+   fuse_passthrough_release(passthrough);
+   kfree(passthrough);
+
+err_free_file:
+   fput(passthrough_filp);
+
+   return res;
 }
 
 int fuse_passthrough_setup(struct fuse_conn *fc, struct fuse_file *ff,
   struct fuse_open_out *openarg)
 {
-   return -EINVAL;
+   struct fuse_passthrough *passthrough;
+   int passthrough_fh = openarg->passthrough_fh;
+
+   if (!fc->passthrough)
+   return -EPERM;
+
+   /* Default case, passthrough is not requested */
+   if (passthrough_fh <= 0)
+   return -EINVAL;
+
+   spin_lock(>passthrough_req_lock);
+   

Re: [PATCH v3 1/3] dt-bindings:drm/bridge:anx7625:add HDCP support flag and swing reg

2021-01-25 Thread Rob Herring
On Mon, Jan 25, 2021 at 07:12:21PM +0800, Xin Ji wrote:
> Add 'bus-type' and 'data-lanes' define for port0, add HDCP support
> flag and DP tx lane0 and lane1 swing register array define.
> 
> Signed-off-by: Xin Ji 
> ---
>  .../bindings/display/bridge/analogix,anx7625.yaml  | 57 
> --
>  1 file changed, 54 insertions(+), 3 deletions(-)
> 
> diff --git 
> a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
> b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> index 60585a4..3b1cbe0 100644
> --- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> +++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> @@ -34,23 +34,69 @@ properties:
>  description: used for reset chip control, RESET_N pin B7.
>  maxItems: 1
>  
> +  analogix,lane0-swing:
> +$ref: /schemas/types.yaml#/definitions/uint32-array
> +description:
> +  an array of swing register setting for DP tx lane0 PHY, please don't
> +  add this property, or contact vendor.
> +
> +  analogix,lane1-swing:
> +$ref: /schemas/types.yaml#/definitions/uint32-array
> +description:
> +  an array of swing register setting for DP tx lane1 PHY, please don't
> +  add this property, or contact vendor.
> +
> +  analogix,hdcp-support:
> +$ref: /schemas/types.yaml#/definitions/uint32
> +description: indicate the DP tx HDCP support or not.

Sounds like a boolean.

> +
>ports:
>  type: object
> +additionalProperties: false
>  
>  properties:
>port@0:
>  type: object
>  description:
> -  Video port for MIPI DSI input.
> +  Video port for MIPI input.

You're going to need to rebase this one drm-misc-next which uses the 
graph schema now.

> +
> +properties:
> +  endpoint:
> +type: object
> +additionalProperties: false
> +
> +# Properties described in
> +# Documentation/devicetree/bindings/media/video-interfaces.txt
> +properties:
> +  remote-endpoint: true
> +  bus-type: true
> +  data-lanes: true
> +
> +required:
> +  - remote-endpoint
> +
> +required:
> +  - endpoint
>  
>port@1:
>  type: object
>  description:
>Video port for panel or connector.
>  
> +properties:
> +  endpoint:
> +type: object
> +additionalProperties: false
> +
> +required:
> +  - remote-endpoint
> +
> +required:
> +  - endpoint
> +
>  required:
> -- port@0
> -- port@1
> +  - port@0
> +  - port@1
>  
>  required:
>- compatible
> @@ -73,6 +119,10 @@ examples:
>  enable-gpios = < 45 GPIO_ACTIVE_HIGH>;
>  reset-gpios = < 73 GPIO_ACTIVE_HIGH>;
>  
> +analogix,lane0-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 0x5b>;
> +analogix,lane1-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 0x5b>;
> +analogix,hdcp-support = <0>;
> +
>  ports {
>  #address-cells = <1>;
>  #size-cells = <0>;
> @@ -81,6 +131,7 @@ examples:
>  reg = <0>;
>  anx7625_in: endpoint {
>  remote-endpoint = <_dsi>;
> +bus-type = <5>;
>  };
>  };
>  
> -- 
> 2.7.4
> 


[PATCH v2 0/7] Generic RB-tree helpers

2021-01-25 Thread Peter Zijlstra


Hai all,

I found myself needing to write yet another rbtree and remembered I had these
patches gathering dust. I've had them in a git tree pretty much ever since I
posted them last and the robot is telling me they build/work/dance/sing fine.

I'm proposing to stick them in tip and get on with life. What say you?




[PATCH RESEND V12 7/8] fuse: Use daemon creds in passthrough mode

2021-01-25 Thread Alessio Balsini
When using FUSE passthrough, read/write operations are directly
forwarded to the lower file system file through VFS, but there is no
guarantee that the process that is triggering the request has the right
permissions to access the lower file system. This would cause the
read/write access to fail.

In passthrough file systems, where the FUSE daemon is responsible for
the enforcement of the lower file system access policies, often happens
that the process dealing with the FUSE file system doesn't have access
to the lower file system.
Being the FUSE daemon in charge of implementing the FUSE file
operations, that in the case of read/write operations usually simply
results in the copy of memory buffers from/to the lower file system
respectively, these operations are executed with the FUSE daemon
privileges.

This patch adds a reference to the FUSE daemon credentials, referenced
at FUSE_DEV_IOC_PASSTHROUGH_OPEN ioctl() time so that they can be used
to temporarily raise the user credentials when accessing lower file
system files in passthrough.
The process accessing the FUSE file with passthrough enabled temporarily
receives the privileges of the FUSE daemon while performing read/write
operations. Similar behavior is implemented in overlayfs.
These privileges will be reverted as soon as the IO operation completes.
This feature does not provide any higher security privileges to those
processes accessing the FUSE file system with passthrough enabled. This
is because it is still the FUSE daemon responsible for enabling or not
the passthrough feature at file open time, and should enable the feature
only after appropriate access policy checks.

Signed-off-by: Alessio Balsini 
---
 fs/fuse/fuse_i.h  |  5 -
 fs/fuse/passthrough.c | 11 +++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index c4730d893324..815af1845b16 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -182,10 +182,13 @@ struct fuse_release_args;
 
 /**
  * Reference to lower filesystem file for read/write operations handled in
- * passthrough mode
+ * passthrough mode.
+ * This struct also tracks the credentials to be used for handling read/write
+ * operations.
  */
 struct fuse_passthrough {
struct file *filp;
+   struct cred *cred;
 };
 
 /** FUSE specific file data */
diff --git a/fs/fuse/passthrough.c b/fs/fuse/passthrough.c
index c7fa1eeb7639..24866c5fe7e2 100644
--- a/fs/fuse/passthrough.c
+++ b/fs/fuse/passthrough.c
@@ -52,6 +52,7 @@ ssize_t fuse_passthrough_read_iter(struct kiocb *iocb_fuse,
   struct iov_iter *iter)
 {
ssize_t ret;
+   const struct cred *old_cred;
struct file *fuse_filp = iocb_fuse->ki_filp;
struct fuse_file *ff = fuse_filp->private_data;
struct file *passthrough_filp = ff->passthrough.filp;
@@ -59,6 +60,7 @@ ssize_t fuse_passthrough_read_iter(struct kiocb *iocb_fuse,
if (!iov_iter_count(iter))
return 0;
 
+   old_cred = override_creds(ff->passthrough.cred);
if (is_sync_kiocb(iocb_fuse)) {
ret = vfs_iter_read(passthrough_filp, iter, _fuse->ki_pos,
iocb_to_rw_flags(iocb_fuse->ki_flags,
@@ -77,6 +79,7 @@ ssize_t fuse_passthrough_read_iter(struct kiocb *iocb_fuse,
if (ret != -EIOCBQUEUED)
fuse_aio_cleanup_handler(aio_req);
}
+   revert_creds(old_cred);
 
return ret;
 }
@@ -85,6 +88,7 @@ ssize_t fuse_passthrough_write_iter(struct kiocb *iocb_fuse,
struct iov_iter *iter)
 {
ssize_t ret;
+   const struct cred *old_cred;
struct file *fuse_filp = iocb_fuse->ki_filp;
struct fuse_file *ff = fuse_filp->private_data;
struct inode *fuse_inode = file_inode(fuse_filp);
@@ -96,6 +100,7 @@ ssize_t fuse_passthrough_write_iter(struct kiocb *iocb_fuse,
 
inode_lock(fuse_inode);
 
+   old_cred = override_creds(ff->passthrough.cred);
if (is_sync_kiocb(iocb_fuse)) {
file_start_write(passthrough_filp);
ret = vfs_iter_write(passthrough_filp, iter, _fuse->ki_pos,
@@ -124,6 +129,7 @@ ssize_t fuse_passthrough_write_iter(struct kiocb *iocb_fuse,
fuse_aio_cleanup_handler(aio_req);
}
 out:
+   revert_creds(old_cred);
inode_unlock(fuse_inode);
 
return ret;
@@ -174,6 +180,7 @@ int fuse_passthrough_open(struct fuse_dev *fud,
}
 
passthrough->filp = passthrough_filp;
+   passthrough->cred = prepare_creds();
 
idr_preload(GFP_KERNEL);
spin_lock(>passthrough_req_lock);
@@ -225,4 +232,8 @@ void fuse_passthrough_release(struct fuse_passthrough 
*passthrough)
fput(passthrough->filp);
passthrough->filp = NULL;
}
+   if (passthrough->cred) {
+   put_cred(passthrough->cred);
+   passthrough->cred 

Re: [PATCH bpf-next v3 3/3] xsk: build skb by page

2021-01-25 Thread Alexander Lobakin
From: Xuan Zhuo 
Date: Mon, 25 Jan 2021 22:57:07 +0800

> On Mon, 25 Jan 2021 13:25:45 +, Alexander Lobakin  wrote:
> > From: Xuan Zhuo 
> > Date: Mon, 25 Jan 2021 11:10:43 +0800
> >
> > > On Fri, 22 Jan 2021 16:24:17 +, Alexander Lobakin  
> > > wrote:
> > > > From: Xuan Zhuo 
> > > > Date: Fri, 22 Jan 2021 23:36:29 +0800
> > > >
> > > > > On Fri, 22 Jan 2021 12:08:00 +, Alexander Lobakin 
> > > > >  wrote:
> > > > > > From: Alexander Lobakin 
> > > > > > Date: Fri, 22 Jan 2021 11:55:35 +
> > > > > >
> > > > > > > From: Alexander Lobakin 
> > > > > > > Date: Fri, 22 Jan 2021 11:47:45 +
> > > > > > >
> > > > > > > > From: Eric Dumazet 
> > > > > > > > Date: Thu, 21 Jan 2021 16:41:33 +0100
> > > > > > > >
> > > > > > > > > On 1/21/21 2:47 PM, Xuan Zhuo wrote:
> > > > > > > > > > This patch is used to construct skb based on page to save 
> > > > > > > > > > memory copy
> > > > > > > > > > overhead.
> > > > > > > > > >
> > > > > > > > > > This function is implemented based on IFF_TX_SKB_NO_LINEAR. 
> > > > > > > > > > Only the
> > > > > > > > > > network card priv_flags supports IFF_TX_SKB_NO_LINEAR will 
> > > > > > > > > > use page to
> > > > > > > > > > directly construct skb. If this feature is not supported, 
> > > > > > > > > > it is still
> > > > > > > > > > necessary to copy data to construct skb.
> > > > > > > > > >
> > > > > > > > > >  Performance Testing 
> > > > > > > > > >
> > > > > > > > > > The test environment is Aliyun ECS server.
> > > > > > > > > > Test cmd:
> > > > > > > > > > ```
> > > > > > > > > > xdpsock -i eth0 -t  -S -s 
> > > > > > > > > > ```
> > > > > > > > > >
> > > > > > > > > > Test result data:
> > > > > > > > > >
> > > > > > > > > > size64  512 10241500
> > > > > > > > > > copy1916747 1775988 1600203 1440054
> > > > > > > > > > page1974058 1953655 1945463 1904478
> > > > > > > > > > percent 3.0%10.0%   21.58%  32.3%
> > > > > > > > > >
> > > > > > > > > > Signed-off-by: Xuan Zhuo 
> > > > > > > > > > Reviewed-by: Dust Li 
> > > > > > > > > > ---
> > > > > > > > > >  net/xdp/xsk.c | 104 
> > > > > > > > > > --
> > > > > > > > > >  1 file changed, 86 insertions(+), 18 deletions(-)
> > > > > > > > > >
> > > > > > > > > > diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> > > > > > > > > > index 4a83117..38af7f1 100644
> > > > > > > > > > --- a/net/xdp/xsk.c
> > > > > > > > > > +++ b/net/xdp/xsk.c
> > > > > > > > > > @@ -430,6 +430,87 @@ static void xsk_destruct_skb(struct 
> > > > > > > > > > sk_buff *skb)
> > > > > > > > > > sock_wfree(skb);
> > > > > > > > > >  }
> > > > > > > > > >
> > > > > > > > > > +static struct sk_buff *xsk_build_skb_zerocopy(struct 
> > > > > > > > > > xdp_sock *xs,
> > > > > > > > > > + struct xdp_desc 
> > > > > > > > > > *desc)
> > > > > > > > > > +{
> > > > > > > > > > +   u32 len, offset, copy, copied;
> > > > > > > > > > +   struct sk_buff *skb;
> > > > > > > > > > +   struct page *page;
> > > > > > > > > > +   void *buffer;
> > > > > > > > > > +   int err, i;
> > > > > > > > > > +   u64 addr;
> > > > > > > > > > +
> > > > > > > > > > +   skb = sock_alloc_send_skb(>sk, 0, 1, );
> > > > > >
> > > > > > Also,
> > > > > > maybe we should allocate it with NET_SKB_PAD so NIC drivers could
> > > > > > use some reserved space?
> > > > > >
> > > > > > skb = sock_alloc_send_skb(>sk, NET_SKB_PAD, 1, 
> > > > > > );
> > > > > > ...
> > > > > > skb_reserve(skb, NET_SKB_PAD);
> > > > > >
> > > > > > Eric, what do you think?
> > > > >
> > > > > I think you are right. Some space should be added to continuous 
> > > > > equipment. This
> > > > > space should also be added in the copy mode below. Is 
> > > > > LL_RESERVED_SPACE more
> > > > > appropriate?
> > > >
> > > > No. If you look at __netdev_alloc_skb() and __napi_alloc_skb(), they
> > > > reserve NET_SKB_PAD at the beginning of linear area. Documentation of
> > > > __build_skb() also says that driver should reserve NET_SKB_PAD before
> > > > the actual frame, so it is a standartized hardware-independent
> > > > headroom.
> > >
> > > I understand that these scenarios are in the case of receiving packets, 
> > > and the
> > > increased space is used by the protocol stack, especially RPS. I don't 
> > > know if
> > > this also applies to the sending scenario?
> > >
> > > > Leaving that space in skb->head will allow developers to implement
> > > > IFF_TX_SKB_NO_LINEAR in a wider variety of drivers, especially when
> > > > a driver has to prepend some sort of data before the actual frame.
> > > > Since it's usually of a size of one cacheline, shouldn't be a big
> > > > deal.
> > > >
> > >
> > > I agree with this. Some network cards require some space. For example,
> > > virtio-net needs to add a virtio_net_hdr_mrg_rxbuf before skb->data, so my
> > > original understanding is used here. When we send the skb 

Re: [PATCH v3 0/2] net: sfp: add support for GPON RTL8672/RTL9601C and Ubiquiti U-Fiber

2021-01-25 Thread Andrew Lunn
> Ok! If this is the only remaining issue, I will update commit messages
> and send a new patch series. I was just waiting for a response if
> somebody else has other comments or if somebody write that is fine with
> it.

Hi Pali

As a general rule of thumb, with netdev, wait 3 days and then send the
next version. If the change request is minor, everybody seems to be in
agreement, you can wait just one day. Please don't send new versions
faster than that.

   Andrew


Re: [PATCH v3 2/6] ALSA: hda/tegra: Reset hardware

2021-01-25 Thread Dmitry Osipenko
25.01.2021 18:18, Takashi Iwai пишет:
> On Wed, 20 Jan 2021 01:31:50 +0100,
> Dmitry Osipenko wrote:
>>
>> Reset hardware on RPM-resume in order to bring it into a predictable
>> state.
>>
>> Tested-by: Peter Geis  # Ouya T30 audio works
>> Tested-by: Matt Merhar  # Ouya T30 boot-tested
>> Tested-by: Nicolas Chauvet  # TK1 boot-tested
>> Signed-off-by: Dmitry Osipenko 
> 
> Currently we have neither dependency nor reverse-selection of
> CONFIG_RESET_CONTROLLER.  It wouldn't be a problem for builds, but
> you'll get a runtime error from
> devm_reset_control_array_get_exclusive() always when
> CONFIG_RESET_CONTROLLER=n.
> 
> I guess it must be a corner case, but just to be sure.

The CONFIG_RESET_CONTROLLER=y at least for ARM32 Tegra builds.

https://elixir.bootlin.com/linux/v5.11-rc5/source/arch/arm/mach-tegra/Kconfig#L15

Not sure about ARM64.


Re: [Linux-stm32] [PATCH] rpmsg: char: return an error if device already open

2021-01-25 Thread Bjorn Andersson
On Fri 15 Jan 03:13 CST 2021, Arnaud POULIQUEN wrote:

> Hi Mathieu,
> 
> 
> On 1/14/21 8:05 PM, Mathieu Poirier wrote:
> > On Wed, Jan 06, 2021 at 02:37:14PM +0100, Arnaud Pouliquen wrote:
> >> The rpmsg_create_ept function is invoked when the device is opened.
> >> As only one endpoint must be created per device. It is not
> >> possible to open the same device twice.
> >> The fix consists in returning -EBUSY when device is already
> >> opened.
> >>
> >> Fixes: c0cdc19f84a4 ("rpmsg: Driver for user space endpoint interface")
> >> Signed-off-by: Arnaud Pouliquen 
> >> ---
> >>  drivers/rpmsg/rpmsg_char.c | 3 +++
> >>  1 file changed, 3 insertions(+)
> >>
> >> diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
> >> index 4bbbacdbf3bb..360a1ab0a9c4 100644
> >> --- a/drivers/rpmsg/rpmsg_char.c
> >> +++ b/drivers/rpmsg/rpmsg_char.c
> >> @@ -127,6 +127,9 @@ static int rpmsg_eptdev_open(struct inode *inode, 
> >> struct file *filp)
> >>struct rpmsg_device *rpdev = eptdev->rpdev;
> >>struct device *dev = >dev;
> >>  
> >> +  if (eptdev->ept)
> >> +  return -EBUSY;
> >> +
> > 
> > I rarely had to work so hard to review a 2 line patch...
> 
> That means that my commit description was not enough explicit...
> 
> > 
> > As far as I can tell the actual code is doing the right thing.  If user 
> > space is
> > trying to open the same eptdev more than once function rpmsg_create_ept() 
> > should
> > complain and the operation denied, wich is what the current code is doing.  
> > 
> > There is currently two customers for this API - SMD and GLINK.  The SMD 
> > code is
> > quite clear that if the channel is already open, the operation will be
> > denied [1].  The GLINK code isn't as clear but the fact that it returns 
> > NULL on
> > error conditions [2] is a good indication that things are working the same 
> > way.
> > 
> > What kind of use case are you looking to address?  Is there any way you can 
> > use
> > rpdev->ops->create_ept() as it is currently done?
> 
> This patch was part of the IOCTL rpmsg series. I sent it separately at Bjorn's
> request [1].
> 

I apparently didn't spend as much effort as Mathieu thinking about the
details. I do believe that he's right, at least both GLINK and SMD
_should_ return -EBUSY if we try to open an already open channel -
either because the kernel has bound a driver to the channel or because
rpmsg_char already has it opened.

> I detect the issue using the RPMSG_ADDR_ANY for the source address when tested
> it with the rpmsf_virtio bus. In this case at each sys open of the device, a 
> new
> endpoint is created because a new source address is allocated.
> 

In SMD and GLINK channels are identified solely by their name and hence
it's not possible to have duplicates. As this isn't the case for virtio
I didn't have any objections to it and that's why I asked you to resend
it separately.

But in line with GLINK/SMD, what would the expected behavior be if I
with the virtio backend open a rpmsg_char which is already bound to a
kernel driver?

Do you think we should get another "channel" or do you think the virtio
driver should detect this and return -EBUSY? (I.e. render this patch
unnecessary)

Regards,
Bjorn

> [1]https://patchwork.kernel.org/project/linux-remoteproc/patch/20201222105726.16906-11-arnaud.pouliq...@foss.st.com/
> 
> Thanks,
> Arnaud
> 
> > 
> > Thanks,
> > Mathieu
> > 
> > [1]. 
> > https://elixir.bootlin.com/linux/v5.11-rc3/source/drivers/rpmsg/qcom_smd.c#L920
> > [2]. 
> > https://elixir.bootlin.com/linux/v5.11-rc3/source/drivers/rpmsg/qcom_glink_native.c#L1149
> > 
> >>get_device(dev);
> >>  
> >>ept = rpmsg_create_ept(rpdev, rpmsg_ept_cb, eptdev, eptdev->chinfo);
> >> -- 
> >> 2.17.1
> >>
> > ___
> > Linux-stm32 mailing list
> > linux-st...@st-md-mailman.stormreply.com
> > https://st-md-mailman.stormreply.com/mailman/listinfo/linux-stm32
> > 


[PATCH v2 3/7] rbtree, sched/deadline: Use rb_add_cached()

2021-01-25 Thread Peter Zijlstra
Reduce rbtree boiler plate by using the new helpers.

Make rb_add_cached() / rb_erase_cached() return a pointer to the
leftmost node to aid in updating additional state.

Signed-off-by: Peter Zijlstra (Intel) 
---
 include/linux/rbtree.h  |   18 ---
 kernel/sched/deadline.c |   77 +---
 2 files changed, 42 insertions(+), 53 deletions(-)

--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -141,12 +141,18 @@ static inline void rb_insert_color_cache
rb_insert_color(node, >rb_root);
 }
 
-static inline void rb_erase_cached(struct rb_node *node,
-  struct rb_root_cached *root)
+
+static inline struct rb_node *
+rb_erase_cached(struct rb_node *node, struct rb_root_cached *root)
 {
+   struct rb_node *leftmost = NULL;
+
if (root->rb_leftmost == node)
-   root->rb_leftmost = rb_next(node);
+   leftmost = root->rb_leftmost = rb_next(node);
+
rb_erase(node, >rb_root);
+
+   return leftmost;
 }
 
 static inline void rb_replace_node_cached(struct rb_node *victim,
@@ -179,8 +185,10 @@ static inline void rb_replace_node_cache
  * @node: node to insert
  * @tree: leftmost cached tree to insert @node into
  * @less: operator defining the (partial) node order
+ *
+ * Returns @node when it is the new leftmost, or NULL.
  */
-static __always_inline void
+static __always_inline struct rb_node *
 rb_add_cached(struct rb_node *node, struct rb_root_cached *tree,
  bool (*less)(struct rb_node *, const struct rb_node *))
 {
@@ -200,6 +208,8 @@ rb_add_cached(struct rb_node *node, stru
 
rb_link_node(node, parent, link);
rb_insert_color_cached(node, tree, leftmost);
+
+   return leftmost ? node : NULL;
 }
 
 /**
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -517,58 +517,44 @@ static void dec_dl_migration(struct sche
update_dl_migration(dl_rq);
 }
 
+#define __node_2_pdl(node) \
+   rb_entry((node), struct task_struct, pushable_dl_tasks)
+
+static inline bool __pushable_less(struct rb_node *a, const struct rb_node *b)
+{
+   return dl_entity_preempt(&__node_2_pdl(a)->dl, &__node_2_pdl(b)->dl);
+}
+
 /*
  * The list of pushable -deadline task is not a plist, like in
  * sched_rt.c, it is an rb-tree with tasks ordered by deadline.
  */
 static void enqueue_pushable_dl_task(struct rq *rq, struct task_struct *p)
 {
-   struct dl_rq *dl_rq = >dl;
-   struct rb_node **link = _rq->pushable_dl_tasks_root.rb_root.rb_node;
-   struct rb_node *parent = NULL;
-   struct task_struct *entry;
-   bool leftmost = true;
+   struct rb_node *leftmost;
 
BUG_ON(!RB_EMPTY_NODE(>pushable_dl_tasks));
 
-   while (*link) {
-   parent = *link;
-   entry = rb_entry(parent, struct task_struct,
-pushable_dl_tasks);
-   if (dl_entity_preempt(>dl, >dl))
-   link = >rb_left;
-   else {
-   link = >rb_right;
-   leftmost = false;
-   }
-   }
-
+   leftmost = rb_add_cached(>pushable_dl_tasks,
+>dl.pushable_dl_tasks_root,
+__pushable_less);
if (leftmost)
-   dl_rq->earliest_dl.next = p->dl.deadline;
-
-   rb_link_node(>pushable_dl_tasks, parent, link);
-   rb_insert_color_cached(>pushable_dl_tasks,
-  _rq->pushable_dl_tasks_root, leftmost);
+   rq->dl.earliest_dl.next = p->dl.deadline;
 }
 
 static void dequeue_pushable_dl_task(struct rq *rq, struct task_struct *p)
 {
struct dl_rq *dl_rq = >dl;
+   struct rb_root_cached *root = _rq->pushable_dl_tasks_root;
+   struct rb_node *leftmost;
 
if (RB_EMPTY_NODE(>pushable_dl_tasks))
return;
 
-   if (dl_rq->pushable_dl_tasks_root.rb_leftmost == >pushable_dl_tasks) 
{
-   struct rb_node *next_node;
-
-   next_node = rb_next(>pushable_dl_tasks);
-   if (next_node) {
-   dl_rq->earliest_dl.next = rb_entry(next_node,
-   struct task_struct, 
pushable_dl_tasks)->dl.deadline;
-   }
-   }
+   leftmost = rb_erase_cached(>pushable_dl_tasks, root);
+   if (leftmost)
+   dl_rq->earliest_dl.next = __node_2_pdl(leftmost)->dl.deadline;
 
-   rb_erase_cached(>pushable_dl_tasks, _rq->pushable_dl_tasks_root);
RB_CLEAR_NODE(>pushable_dl_tasks);
 }
 
@@ -1478,29 +1464,21 @@ void dec_dl_tasks(struct sched_dl_entity
dec_dl_migration(dl_se, dl_rq);
 }
 
+#define __node_2_dle(node) \
+   rb_entry((node), struct sched_dl_entity, rb_node)
+
+static inline bool __dl_less(struct rb_node *a, const struct rb_node *b)
+{
+   return dl_time_before(__node_2_dle(a)->deadline, 
__node_2_dle(b)->deadline);
+}
+
 static void 

[PATCH v2 2/7] rbtree, sched/fair: Use rb_add_cached()

2021-01-25 Thread Peter Zijlstra
Reduce rbtree boiler plate by using the new helper function.

Signed-off-by: Peter Zijlstra (Intel) 
---
 kernel/sched/fair.c |   46 ++
 1 file changed, 14 insertions(+), 32 deletions(-)

--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -533,12 +533,15 @@ static inline u64 min_vruntime(u64 min_v
return min_vruntime;
 }
 
-static inline int entity_before(struct sched_entity *a,
+static inline bool entity_before(struct sched_entity *a,
struct sched_entity *b)
 {
return (s64)(a->vruntime - b->vruntime) < 0;
 }
 
+#define __node_2_se(node) \
+   rb_entry((node), struct sched_entity, run_node)
+
 static void update_min_vruntime(struct cfs_rq *cfs_rq)
 {
struct sched_entity *curr = cfs_rq->curr;
@@ -554,8 +557,7 @@ static void update_min_vruntime(struct c
}
 
if (leftmost) { /* non-empty tree */
-   struct sched_entity *se;
-   se = rb_entry(leftmost, struct sched_entity, run_node);
+   struct sched_entity *se = __node_2_se(leftmost);
 
if (!curr)
vruntime = se->vruntime;
@@ -571,37 +573,17 @@ static void update_min_vruntime(struct c
 #endif
 }
 
+static inline bool __entity_less(struct rb_node *a, const struct rb_node *b)
+{
+   return entity_before(__node_2_se(a), __node_2_se(b));
+}
+
 /*
  * Enqueue an entity into the rb-tree:
  */
 static void __enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
 {
-   struct rb_node **link = _rq->tasks_timeline.rb_root.rb_node;
-   struct rb_node *parent = NULL;
-   struct sched_entity *entry;
-   bool leftmost = true;
-
-   /*
-* Find the right place in the rbtree:
-*/
-   while (*link) {
-   parent = *link;
-   entry = rb_entry(parent, struct sched_entity, run_node);
-   /*
-* We dont care about collisions. Nodes with
-* the same key stay together.
-*/
-   if (entity_before(se, entry)) {
-   link = >rb_left;
-   } else {
-   link = >rb_right;
-   leftmost = false;
-   }
-   }
-
-   rb_link_node(>run_node, parent, link);
-   rb_insert_color_cached(>run_node,
-  _rq->tasks_timeline, leftmost);
+   rb_add_cached(>run_node, _rq->tasks_timeline, __entity_less);
 }
 
 static void __dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
@@ -616,7 +598,7 @@ struct sched_entity *__pick_first_entity
if (!left)
return NULL;
 
-   return rb_entry(left, struct sched_entity, run_node);
+   return __node_2_se(left);
 }
 
 static struct sched_entity *__pick_next_entity(struct sched_entity *se)
@@ -626,7 +608,7 @@ static struct sched_entity *__pick_next_
if (!next)
return NULL;
 
-   return rb_entry(next, struct sched_entity, run_node);
+   return __node_2_se(next);
 }
 
 #ifdef CONFIG_SCHED_DEBUG
@@ -637,7 +619,7 @@ struct sched_entity *__pick_last_entity(
if (!last)
return NULL;
 
-   return rb_entry(last, struct sched_entity, run_node);
+   return __node_2_se(last);
 }
 
 /**




[PATCH v2 6/7] rbtree, rtmutex: Use rb_add_cached()

2021-01-25 Thread Peter Zijlstra
Reduce rbtree boiler plate by using the new helpers.

Signed-off-by: Peter Zijlstra (Intel) 
---
 kernel/locking/rtmutex.c |   54 +++
 1 file changed, 18 insertions(+), 36 deletions(-)

--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -267,27 +267,18 @@ rt_mutex_waiter_equal(struct rt_mutex_wa
return 1;
 }
 
+#define __node_2_waiter(node) \
+   rb_entry((node), struct rt_mutex_waiter, tree_entry)
+
+static inline bool __waiter_less(struct rb_node *a, const struct rb_node *b)
+{
+   return rt_mutex_waiter_less(__node_2_waiter(a), __node_2_waiter(b));
+}
+
 static void
 rt_mutex_enqueue(struct rt_mutex *lock, struct rt_mutex_waiter *waiter)
 {
-   struct rb_node **link = >waiters.rb_root.rb_node;
-   struct rb_node *parent = NULL;
-   struct rt_mutex_waiter *entry;
-   bool leftmost = true;
-
-   while (*link) {
-   parent = *link;
-   entry = rb_entry(parent, struct rt_mutex_waiter, tree_entry);
-   if (rt_mutex_waiter_less(waiter, entry)) {
-   link = >rb_left;
-   } else {
-   link = >rb_right;
-   leftmost = false;
-   }
-   }
-
-   rb_link_node(>tree_entry, parent, link);
-   rb_insert_color_cached(>tree_entry, >waiters, leftmost);
+   rb_add_cached(>tree_entry, >waiters, __waiter_less);
 }
 
 static void
@@ -300,27 +291,18 @@ rt_mutex_dequeue(struct rt_mutex *lock,
RB_CLEAR_NODE(>tree_entry);
 }
 
+#define __node_2_pi_waiter(node) \
+   rb_entry((node), struct rt_mutex_waiter, pi_tree_entry)
+
+static inline bool __pi_waiter_less(struct rb_node *a, const struct rb_node *b)
+{
+   return rt_mutex_waiter_less(__node_2_pi_waiter(a), 
__node_2_pi_waiter(b));
+}
+
 static void
 rt_mutex_enqueue_pi(struct task_struct *task, struct rt_mutex_waiter *waiter)
 {
-   struct rb_node **link = >pi_waiters.rb_root.rb_node;
-   struct rb_node *parent = NULL;
-   struct rt_mutex_waiter *entry;
-   bool leftmost = true;
-
-   while (*link) {
-   parent = *link;
-   entry = rb_entry(parent, struct rt_mutex_waiter, pi_tree_entry);
-   if (rt_mutex_waiter_less(waiter, entry)) {
-   link = >rb_left;
-   } else {
-   link = >rb_right;
-   leftmost = false;
-   }
-   }
-
-   rb_link_node(>pi_tree_entry, parent, link);
-   rb_insert_color_cached(>pi_tree_entry, >pi_waiters, 
leftmost);
+   rb_add_cached(>pi_tree_entry, >pi_waiters, 
__pi_waiter_less);
 }
 
 static void




[PATCH v2 7/7] rbtree, timerqueue: Use rb_add_cached()

2021-01-25 Thread Peter Zijlstra
Reduce rbtree boiler plate by using the new helpers.

Signed-off-by: Peter Zijlstra (Intel) 
---
 lib/timerqueue.c |   28 +---
 1 file changed, 9 insertions(+), 19 deletions(-)

--- a/lib/timerqueue.c
+++ b/lib/timerqueue.c
@@ -14,6 +14,14 @@
 #include 
 #include 
 
+#define __node_2_tq(_n) \
+   rb_entry((_n), struct timerqueue_node, node)
+
+static inline bool __timerqueue_less(struct rb_node *a, const struct rb_node 
*b)
+{
+   return __node_2_tq(a)->expires < __node_2_tq(b)->expires;
+}
+
 /**
  * timerqueue_add - Adds timer to timerqueue.
  *
@@ -26,28 +34,10 @@
  */
 bool timerqueue_add(struct timerqueue_head *head, struct timerqueue_node *node)
 {
-   struct rb_node **p = >rb_root.rb_root.rb_node;
-   struct rb_node *parent = NULL;
-   struct timerqueue_node *ptr;
-   bool leftmost = true;
-
/* Make sure we don't add nodes that are already added */
WARN_ON_ONCE(!RB_EMPTY_NODE(>node));
 
-   while (*p) {
-   parent = *p;
-   ptr = rb_entry(parent, struct timerqueue_node, node);
-   if (node->expires < ptr->expires) {
-   p = &(*p)->rb_left;
-   } else {
-   p = &(*p)->rb_right;
-   leftmost = false;
-   }
-   }
-   rb_link_node(>node, parent, p);
-   rb_insert_color_cached(>node, >rb_root, leftmost);
-
-   return leftmost;
+   return rb_add_cached(>node, >rb_root, __timerqueue_less);
 }
 EXPORT_SYMBOL_GPL(timerqueue_add);
 




[kbuild] Re: [PATCH v2 11/12][RESEND] iio: buffer: introduce support for attaching more IIO buffers

2021-01-25 Thread Dan Carpenter
Hi Alexandru,

I love your patch! Perhaps something to improve:

url:
https://github.com/0day-ci/linux/commits/Alexandru-Ardelean/iio-core-buffer-add-support-for-multiple-IIO-buffers-per-IIO-device/20210125-053419
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git  togreg
config: i386-randconfig-m021-20210125 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-20) 9.3.0

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

smatch warnings:
drivers/iio/industrialio-buffer.c:1606 iio_buffer_alloc_sysfs_and_mask() error: 
uninitialized symbol 'cnt'.

vim +/cnt +1606 drivers/iio/industrialio-buffer.c

e16e0a778fec8ac1 Alexandru Ardelean 2020-09-17  1562  int 
iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
d967cb6bd4e79c0c Lars-Peter Clausen 2014-11-26  1563  {
8b70c93a9d04de1e Alexandru Ardelean 2021-01-22  1564struct iio_dev_opaque 
*iio_dev_opaque = to_iio_dev_opaque(indio_dev);
ff3f7e049aef9202 Alexandru Ardelean 2020-04-24  1565struct iio_buffer 
*buffer = indio_dev->buffer;
e16e0a778fec8ac1 Alexandru Ardelean 2020-09-17  1566const struct 
iio_chan_spec *channels;
8b70c93a9d04de1e Alexandru Ardelean 2021-01-22  1567int i, cnt, ret;
e16e0a778fec8ac1 Alexandru Ardelean 2020-09-17  1568  
e16e0a778fec8ac1 Alexandru Ardelean 2020-09-17  1569channels = 
indio_dev->channels;
e16e0a778fec8ac1 Alexandru Ardelean 2020-09-17  1570if (channels) {
e16e0a778fec8ac1 Alexandru Ardelean 2020-09-17  1571int ml = 
indio_dev->masklength;
e16e0a778fec8ac1 Alexandru Ardelean 2020-09-17  1572  
e16e0a778fec8ac1 Alexandru Ardelean 2020-09-17  1573for (i = 0; i < 
indio_dev->num_channels; i++)
e16e0a778fec8ac1 Alexandru Ardelean 2020-09-17  1574ml = 
max(ml, channels[i].scan_index + 1);
e16e0a778fec8ac1 Alexandru Ardelean 2020-09-17  1575
indio_dev->masklength = ml;
e16e0a778fec8ac1 Alexandru Ardelean 2020-09-17  1576}
ff3f7e049aef9202 Alexandru Ardelean 2020-04-24  1577  
ff3f7e049aef9202 Alexandru Ardelean 2020-04-24  1578if (!buffer)
e16e0a778fec8ac1 Alexandru Ardelean 2020-09-17  1579return 0;
e16e0a778fec8ac1 Alexandru Ardelean 2020-09-17  1580  
8b70c93a9d04de1e Alexandru Ardelean 2021-01-22  1581for (i = 0; i < 
iio_dev_opaque->attached_buffers_cnt; i++) {
8b70c93a9d04de1e Alexandru Ardelean 2021-01-22  1582buffer = 
iio_dev_opaque->attached_buffers[i];
8b70c93a9d04de1e Alexandru Ardelean 2021-01-22  1583ret = 
__iio_buffer_alloc_sysfs_and_mask(buffer, indio_dev, i);
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1584if (ret)
8b70c93a9d04de1e Alexandru Ardelean 2021-01-22  1585goto 
error_unwind_sysfs_and_mask;

"cnt" is not set here.

8b70c93a9d04de1e Alexandru Ardelean 2021-01-22  1586}
d967cb6bd4e79c0c Lars-Peter Clausen 2014-11-26  1587  
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1588ret = 
sysfs_create_link(_dev->dev.kobj,
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1589
_dev->buffer->buffer_dir,
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1590
"buffer");
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1591if (ret)
8b70c93a9d04de1e Alexandru Ardelean 2021-01-22  1592goto 
error_unwind_sysfs_and_mask;

Oh here.

e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1593  
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1594ret = 
sysfs_create_link(_dev->dev.kobj,
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1595
_dev->buffer->scan_el_dir,
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1596
"scan_elements");
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1597if (ret)
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1598goto 
error_remove_buffer_dir_link;
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1599  
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1600return 0;
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1601  
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1602  
error_remove_buffer_dir_link:
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1603
sysfs_remove_link(_dev->dev.kobj, "buffer");
8b70c93a9d04de1e Alexandru Ardelean 2021-01-22  1604cnt = 
iio_dev_opaque->attached_buffers_cnt - 1;
8b70c93a9d04de1e Alexandru Ardelean 2021-01-22  1605  
error_unwind_sysfs_and_mask:
8b70c93a9d04de1e Alexandru Ardelean 2021-01-22 @1606for (; cnt >= 0; cnt--) 
{
   
Uninitialized.

8b70c93a9d04de1e Alexandru Ardelean 2021-01-22  1607buffer = 
iio_dev_opaque->attached_buffers[cnt];
e2eb176de4748db8 Alexandru Ardelean 2021-01-22  1608
__iio_buffer_free_sysfs_and_mask(buffer);
8b70c93a9d04d

Re: [PATCH] drm/amd/display: fix unused variable warning

2021-01-25 Thread Harry Wentland

On 2021-01-25 7:48 a.m., Arnd Bergmann wrote:

From: Arnd Bergmann 

After all users of the 'dm' warnings got hidden in an #ifdef,
the compiler started warning about it being unused:

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:5380:33: error: 
unused variable 'dm' [-Werror,-Wunused-variable]

Add another such #ifdef.

Fixes: 98ab5f3513f9 ("drm/amd/display: Fix deadlock during gpu reset v3")
Signed-off-by: Arnd Bergmann 


Reviewed-by: Harry Wentland 

Harry


---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a90dc4d31c32..37bf2dd87e1e 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -5377,7 +5377,9 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, 
bool enable)
struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
struct amdgpu_device *adev = drm_to_adev(crtc->dev);
struct dm_crtc_state *acrtc_state = to_dm_crtc_state(crtc->state);
+#if defined(CONFIG_DRM_AMD_DC_DCN)
struct amdgpu_display_manager *dm = >dm;
+#endif
int rc = 0;
  
  	if (enable) {




[PATCH v4 14/21] net: stmmac: dwmac-sun8i: Prepare for second EMAC clock register

2021-01-25 Thread Andre Przywara
The Allwinner H616 SoC has two EMAC controllers, with the second one
being tied to the internal PHY, but also using a separate EMAC clock
register.

To tell the driver about which clock register to use, we add a parameter
to our syscon phandle. The driver will use this value as an index into
the regmap, so that we can address more than the first register, if
needed.

Signed-off-by: Andre Przywara 
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 58e0511badba..c7951790ed98 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -1124,11 +1124,13 @@ static int sun8i_dwmac_probe(struct platform_device 
*pdev)
struct stmmac_resources stmmac_res;
struct sunxi_priv_data *gmac;
struct device *dev = >dev;
+   struct reg_field syscon_field;
phy_interface_t interface;
int ret;
struct stmmac_priv *priv;
struct net_device *ndev;
struct regmap *regmap;
+   u32 syscon_idx = 0;
 
ret = stmmac_get_platform_resources(pdev, _res);
if (ret)
@@ -1190,8 +1192,12 @@ static int sun8i_dwmac_probe(struct platform_device 
*pdev)
return ret;
}
 
-   gmac->regmap_field = devm_regmap_field_alloc(dev, regmap,
-
*gmac->variant->syscon_field);
+   syscon_field = *gmac->variant->syscon_field;
+   ret = of_property_read_u32_index(pdev->dev.of_node, "syscon", 1,
+_idx);
+   if (!ret)
+   syscon_field.reg += syscon_idx * sizeof(u32);
+   gmac->regmap_field = devm_regmap_field_alloc(dev, regmap, syscon_field);
if (IS_ERR(gmac->regmap_field)) {
ret = PTR_ERR(gmac->regmap_field);
dev_err(dev, "Unable to map syscon register: %d\n", ret);
@@ -1263,6 +1269,8 @@ static const struct of_device_id sun8i_dwmac_match[] = {
.data = _variant_a64 },
{ .compatible = "allwinner,sun50i-h6-emac",
.data = _variant_h6 },
+   { .compatible = "allwinner,sun50i-h616-emac",
+   .data = _variant_h6 },
{ }
 };
 MODULE_DEVICE_TABLE(of, sun8i_dwmac_match);
-- 
2.17.5



[PATCH v4 11/21] dt-bindings: media: IR: Add H616 IR compatible string

2021-01-25 Thread Andre Przywara
Add the obvious compatible name to the existing IR binding, and pair
it with the existing A31 fallback compatible string, as the devices
are compatible.

On the way use enums to group all compatible devices together.

Signed-off-by: Andre Przywara 
Acked-by: Rob Herring 
---
 .../bindings/media/allwinner,sun4i-a10-ir.yaml   | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git 
a/Documentation/devicetree/bindings/media/allwinner,sun4i-a10-ir.yaml 
b/Documentation/devicetree/bindings/media/allwinner,sun4i-a10-ir.yaml
index 5fa19d4aeaf3..6d8395d6bca0 100644
--- a/Documentation/devicetree/bindings/media/allwinner,sun4i-a10-ir.yaml
+++ b/Documentation/devicetree/bindings/media/allwinner,sun4i-a10-ir.yaml
@@ -20,16 +20,12 @@ properties:
   - const: allwinner,sun5i-a13-ir
   - const: allwinner,sun6i-a31-ir
   - items:
-  - const: allwinner,sun8i-a83t-ir
-  - const: allwinner,sun6i-a31-ir
-  - items:
-  - const: allwinner,sun8i-r40-ir
-  - const: allwinner,sun6i-a31-ir
-  - items:
-  - const: allwinner,sun50i-a64-ir
-  - const: allwinner,sun6i-a31-ir
-  - items:
-  - const: allwinner,sun50i-h6-ir
+  - enum:
+  - allwinner,sun8i-a83t-ir
+  - allwinner,sun8i-r40-ir
+  - allwinner,sun50i-a64-ir
+  - allwinner,sun50i-h6-ir
+  - allwinner,sun50i-h616-ir
   - const: allwinner,sun6i-a31-ir
 
   reg:
-- 
2.17.5



[PATCH v4 09/21] dt-bindings: watchdog: sun4i: Add H616 compatible string

2021-01-25 Thread Andre Przywara
Use enums to group all compatible devices together on the way.

Signed-off-by: Andre Przywara 
Acked-by: Rob Herring 
Acked-by: Maxime Ripard 
Reviewed-by: Guenter Roeck 
---
 .../bindings/watchdog/allwinner,sun4i-a10-wdt.yaml   | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git 
a/Documentation/devicetree/bindings/watchdog/allwinner,sun4i-a10-wdt.yaml 
b/Documentation/devicetree/bindings/watchdog/allwinner,sun4i-a10-wdt.yaml
index 5ac607de8be4..9aa3c313c49f 100644
--- a/Documentation/devicetree/bindings/watchdog/allwinner,sun4i-a10-wdt.yaml
+++ b/Documentation/devicetree/bindings/watchdog/allwinner,sun4i-a10-wdt.yaml
@@ -19,13 +19,11 @@ properties:
   - const: allwinner,sun4i-a10-wdt
   - const: allwinner,sun6i-a31-wdt
   - items:
-  - const: allwinner,sun50i-a64-wdt
-  - const: allwinner,sun6i-a31-wdt
-  - items:
-  - const: allwinner,sun50i-a100-wdt
-  - const: allwinner,sun6i-a31-wdt
-  - items:
-  - const: allwinner,sun50i-h6-wdt
+  - enum:
+  - allwinner,sun50i-a64-wdt
+  - allwinner,sun50i-a100-wdt
+  - allwinner,sun50i-h6-wdt
+  - allwinner,sun50i-h616-wdt
   - const: allwinner,sun6i-a31-wdt
   - items:
   - const: allwinner,suniv-f1c100s-wdt
-- 
2.17.5



[PATCH v4 12/21] dt-bindings: rtc: sun6i: Add H616 compatible string

2021-01-25 Thread Andre Przywara
Add the obvious compatible name to the existing RTC binding, and pair
it with the existing H6 fallback compatible string, as the devices are
compatible.

Signed-off-by: Andre Przywara 
Acked-by: Rob Herring 
---
 .../devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml   | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml 
b/Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml
index b1b0ee769b71..4193e5813344 100644
--- a/Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml
+++ b/Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml
@@ -26,6 +26,9 @@ properties:
   - const: allwinner,sun50i-a64-rtc
   - const: allwinner,sun8i-h3-rtc
   - const: allwinner,sun50i-h6-rtc
+  - items:
+  - const: allwinner,sun50i-h616-rtc
+  - const: allwinner,sun50i-h6-rtc
 
   reg:
 maxItems: 1
-- 
2.17.5



[PATCH v4 20/21] dt-bindings: arm: sunxi: Add OrangePi Zero 2 binding

2021-01-25 Thread Andre Przywara
Signed-off-by: Andre Przywara 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/arm/sunxi.yaml | 5 +
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/sunxi.yaml 
b/Documentation/devicetree/bindings/arm/sunxi.yaml
index 08607c7ec1bf..aeb8771b14c4 100644
--- a/Documentation/devicetree/bindings/arm/sunxi.yaml
+++ b/Documentation/devicetree/bindings/arm/sunxi.yaml
@@ -932,4 +932,9 @@ properties:
   - const: xunlong,orangepi-zero-plus2-h3
   - const: allwinner,sun8i-h3
 
+  - description: Xunlong OrangePi Zero 2
+items:
+  - const: xunlong,orangepi-zero2
+  - const: allwinner,sun50i-h616
+
 additionalProperties: true
-- 
2.17.5



[PATCH v4 16/21] dt-bindings: usb: Add H616 compatible string

2021-01-25 Thread Andre Przywara
The H616 has four PHYs as the H3, along with their respective clock
gates and resets, so the property description is identical.

However the PHYs itself need some special bits, so we need a new
compatible string for it.

Signed-off-by: Andre Przywara 
---
 .../devicetree/bindings/phy/allwinner,sun8i-h3-usb-phy.yaml   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/Documentation/devicetree/bindings/phy/allwinner,sun8i-h3-usb-phy.yaml 
b/Documentation/devicetree/bindings/phy/allwinner,sun8i-h3-usb-phy.yaml
index 60c344585276..b76a1803dc5f 100644
--- a/Documentation/devicetree/bindings/phy/allwinner,sun8i-h3-usb-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/allwinner,sun8i-h3-usb-phy.yaml
@@ -15,7 +15,9 @@ properties:
 const: 1
 
   compatible:
-const: allwinner,sun8i-h3-usb-phy
+enum:
+  - allwinner,sun8i-h3-usb-phy
+  - allwinner,sun50i-h616-usb-phy
 
   reg:
 items:
-- 
2.17.5



[PATCH v4 21/21] arm64: dts: allwinner: Add OrangePi Zero 2 .dts

2021-01-25 Thread Andre Przywara
The OrangePi Zero 2 is a development board with the new H616 SoC.

It features the usual connectors used on those small boards, and comes
with the AXP305, which seems to be compatible with the AXP805.

For more details see: http://linux-sunxi.org/Xunlong_Orange_Pi_Zero2

Signed-off-by: Andre Przywara 
---
 arch/arm64/boot/dts/allwinner/Makefile|   1 +
 .../allwinner/sun50i-h616-orangepi-zero2.dts  | 242 ++
 2 files changed, 243 insertions(+)
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts

diff --git a/arch/arm64/boot/dts/allwinner/Makefile 
b/arch/arm64/boot/dts/allwinner/Makefile
index 41ce680e5f8d..9ba4b5d92657 100644
--- a/arch/arm64/boot/dts/allwinner/Makefile
+++ b/arch/arm64/boot/dts/allwinner/Makefile
@@ -36,3 +36,4 @@ dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h6-orangepi-one-plus.dtb
 dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h6-pine-h64.dtb
 dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h6-pine-h64-model-b.dtb
 dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h6-tanix-tx6.dtb
+dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h616-orangepi-zero2.dtb
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts 
b/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts
new file mode 100644
index ..e6de49f89e39
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts
@@ -0,0 +1,242 @@
+// SPDX-License-Identifier: (GPL-2.0+ or MIT)
+/*
+ * Copyright (C) 2020 Arm Ltd.
+ */
+
+/dts-v1/;
+
+#include "sun50i-h616.dtsi"
+
+#include 
+#include 
+#include 
+
+/ {
+   model = "OrangePi Zero2";
+   compatible = "xunlong,orangepi-zero2", "allwinner,sun50i-h616";
+
+   aliases {
+   ethernet0 = 
+   serial0 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   led-0 {
+   function = LED_FUNCTION_POWER;
+   color = ;
+   gpios = < 2 12 GPIO_ACTIVE_HIGH>; /* PC12 */
+   default-state = "on";
+   };
+
+   led-1 {
+   function = LED_FUNCTION_STATUS;
+   color = ;
+   gpios = < 2 13 GPIO_ACTIVE_HIGH>; /* PC13 */
+   };
+   };
+
+   reg_vcc5v: vcc5v {
+   /* board wide 5V supply directly from the USB-C socket */
+   compatible = "regulator-fixed";
+   regulator-name = "vcc-5v";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   regulator-always-on;
+   };
+
+   reg_usb1_vbus: usb1-vbus {
+   compatible = "regulator-fixed";
+   regulator-name = "usb1-vbus";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_vcc5v>;
+   enable-active-high;
+   gpio = < 2 16 GPIO_ACTIVE_HIGH>; /* PC16 */
+   status = "okay";
+   };
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+/* USB 2 & 3 are on headers only. */
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_rgmii_pins>;
+   phy-mode = "rgmii";
+   phy-handle = <_rgmii_phy>;
+   phy-supply = <_dcdce>;
+   allwinner,rx-delay-ps = <3100>;
+   allwinner,tx-delay-ps = <700>;
+   status = "okay";
+};
+
+ {
+   ext_rgmii_phy: ethernet-phy@1 {
+   compatible = "ethernet-phy-ieee802.3-c22";
+   reg = <1>;
+   };
+};
+
+ {
+   vmmc-supply = <_dcdce>;
+   cd-gpios = < 5 6 GPIO_ACTIVE_LOW>;  /* PF6 */
+   bus-width = <4>;
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+_rsb {
+   status = "okay";
+
+   axp305: pmic@745 {
+   compatible = "x-powers,axp305", "x-powers,axp805",
+"x-powers,axp806";
+   interrupt-controller;
+   #interrupt-cells = <1>;
+   reg = <0x745>;
+
+   x-powers,self-working-mode;
+   vina-supply = <_vcc5v>;
+   vinb-supply = <_vcc5v>;
+   vinc-supply = <_vcc5v>;
+   vind-supply = <_vcc5v>;
+   vine-supply = <_vcc5v>;
+   aldoin-supply = <_vcc5v>;
+   bldoin-supply = <_vcc5v>;
+   cldoin-supply = <_vcc5v>;
+
+   regulators {
+   reg_aldo1: aldo1 {
+   regulator-always-on;
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-name = "vcc-sys";
+   };
+
+   reg_aldo2: aldo2 {  /* 3.3V on headers */
+   regulator-always-on;
+  

[PATCH v4 10/21] dt-bindings: i2c: mv64xxx: Add H616 compatible string

2021-01-25 Thread Andre Przywara
Add the obvious compatible name to the existing I2C binding, and pair
it with the existing A31 fallback compatible string, as the devices
are compatible.

On the way use enums to group all compatible devices together.

Signed-off-by: Andre Przywara 
Acked-by: Rob Herring 
Acked-by: Wolfram Sang 
---
 .../bindings/i2c/marvell,mv64xxx-i2c.yaml | 21 +++
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/Documentation/devicetree/bindings/i2c/marvell,mv64xxx-i2c.yaml 
b/Documentation/devicetree/bindings/i2c/marvell,mv64xxx-i2c.yaml
index 5b5ae402f97a..eb72dd571def 100644
--- a/Documentation/devicetree/bindings/i2c/marvell,mv64xxx-i2c.yaml
+++ b/Documentation/devicetree/bindings/i2c/marvell,mv64xxx-i2c.yaml
@@ -18,21 +18,14 @@ properties:
   - const: allwinner,sun4i-a10-i2c
   - const: allwinner,sun6i-a31-i2c
   - items:
-  - const: allwinner,sun8i-a23-i2c
+  - enum:
+  - allwinner,sun8i-a23-i2c
+  - allwinner,sun8i-a83t-i2c
+  - allwinner,sun50i-a64-i2c
+  - allwinner,sun50i-a100-i2c
+  - allwinner,sun50i-h6-i2c
+  - allwinner,sun50i-h616-i2c
   - const: allwinner,sun6i-a31-i2c
-  - items:
-  - const: allwinner,sun8i-a83t-i2c
-  - const: allwinner,sun6i-a31-i2c
-  - items:
-  - const: allwinner,sun50i-a64-i2c
-  - const: allwinner,sun6i-a31-i2c
-  - items:
-  - const: allwinner,sun50i-a100-i2c
-  - const: allwinner,sun6i-a31-i2c
-  - items:
-  - const: allwinner,sun50i-h6-i2c
-  - const: allwinner,sun6i-a31-i2c
-
   - const: marvell,mv64xxx-i2c
   - const: marvell,mv78230-i2c
   - const: marvell,mv78230-a0-i2c
-- 
2.17.5



Re: [PATCH 1/2] media: venus: core: Add sdm660 DT compatible and resource struct

2021-01-25 Thread Hans Verkuil
On 25/01/2021 15:51, AngeloGioacchino Del Regno wrote:
> Il 25/01/21 11:40, Hans Verkuil ha scritto:
>> On 18/01/2021 18:45, AngeloGioacchino Del Regno wrote:
>>> Il 18/01/21 18:21, Stanimir Varbanov ha scritto:
 Hi Angelo,

 Thanks for the patch!

 On 1/15/21 8:52 PM, AngeloGioacchino Del Regno wrote:
> Add the SDM660 DT compatible and its resource structure, also
> including support for the Venus pmdomains, in order to support
> the Venus block in SDM630, SDM636, SDM660 and SDA variants.
>
> This SoC features Venus 4.4 (HFI3XX), with one vcodec used for
> both encoding and decoding, switched on through two GDSCs.
> The core clock for this Venus chip is powered by the RPM VDD_CX
> power domain.
>
> Signed-off-by: AngeloGioacchino Del Regno 
> 
> ---
>drivers/media/platform/qcom/venus/core.c | 66 
>1 file changed, 66 insertions(+)
>
> diff --git a/drivers/media/platform/qcom/venus/core.c 
> b/drivers/media/platform/qcom/venus/core.c
> index bdd293faaad0..83ca86a63241 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -565,6 +565,71 @@ static const struct venus_resources sdm845_res_v2 = {
>   .fwname = "qcom/venus-5.2/venus.mdt",
>};
>
> +static const struct freq_tbl sdm660_freq_table[] = {
> + { 0, 51840 },
> + { 0, 44160 },
> + { 0, 40400 },
> + { 0, 32000 },
> + { 0, 26933 },
> + { 0, 1 },
> +};
> +
> +static const struct reg_val sdm660_reg_preset[] = {
> + { 0x80010, 0x001f001f },
> + { 0x80018, 0x0156 },
> + { 0x8001C, 0x0156 },
> +};
> +
> +static const struct bw_tbl sdm660_bw_table_enc[] = {
> + {  979200,  1044000, 0, 2446336, 0 },   /* 4k UHD @ 30 */
> + {  864000,   887000, 0, 2108416, 0 },   /* 720p @ 240 */
> + {  489600,   666000, 0, 1207296, 0 },   /* 1080p @ 60 */
> + {  432000,   578000, 0, 1058816, 0 },   /* 720p @ 120 */
> + {  244800,   346000, 0,  616448, 0 },   /* 1080p @ 30 */
> + {  216000,   293000, 0,  534528, 0 },   /* 720p @ 60 */
> + {  108000,   151000, 0,  271360, 0 },   /* 720p @ 30 */
> +};
> +
> +static const struct bw_tbl sdm660_bw_table_dec[] = {
> + {  979200,  2365000, 0, 1892000, 0 },   /* 4k UHD @ 30 */
> + {  864000,  1978000, 0, 1554000, 0 },   /* 720p @ 240 */
> + {  489600,  1133000, 0,  895000, 0 },   /* 1080p @ 60 */
> + {  432000,   994000, 0,  781000, 0 },   /* 720p @ 120 */
> + {  244800,   58, 0,  46, 0 },   /* 1080p @ 30 */
> + {  216000,   501000, 0,  301000, 0 },   /* 720p @ 60 */
> + {  108000,   255000, 0,  202000, 0 },   /* 720p @ 30 */
> +};
> +
> +static const struct venus_resources sdm660_res = {
> + .freq_tbl = sdm660_freq_table,
> + .freq_tbl_size = ARRAY_SIZE(sdm660_freq_table),
> + .reg_tbl = sdm660_reg_preset,
> + .reg_tbl_size = ARRAY_SIZE(sdm660_reg_preset),
> + .bw_tbl_enc = sdm660_bw_table_enc,
> + .bw_tbl_enc_size = ARRAY_SIZE(sdm660_bw_table_enc),
> + .bw_tbl_dec = sdm660_bw_table_dec,
> + .bw_tbl_dec_size = ARRAY_SIZE(sdm660_bw_table_dec),
> + .clks = {"core", "iface", "bus_throttle", "bus" },
> + .clks_num = 4,
> + .vcodec0_clks = { "vcodec0_core" },
> + .vcodec_clks_num = 1,
> + .vcodec_pmdomains = { "venus", "vcodec0" },
> + .vcodec_pmdomains_num = 2,
> + .opp_pmdomain = (const char *[]) { "cx", NULL },
> + .vcodec_num = 1,
> + .max_load = 1036800,
> + .hfi_version = HFI_VERSION_3XX,
> + .vmem_id = VIDC_RESOURCE_NONE,
> + .vmem_size = 0,
> + .vmem_addr = 0,
> + .cp_start = 0,
> + .cp_size = 0x7900,
> + .cp_nonpixel_start = 0x100,
> + .cp_nonpixel_size = 0x2800,
> + .dma_mask = 0xd900 - 1,
> + .fwname = "qcom/venus-4.4/venus.mdt",

 Did you try venus-4.2 firmware from linux-firmware tree [1] ?

>>>
>>> No I haven't.. and I can't... my Sony devices (but I think that this is
>>> a practice of all OEMs/ODMs) are using a Sony signed venus firmware, so
>>> I am totally limited to use the firmware that comes with the device.
>>>
>>> Besides that, the version is still different so, even if I had any
>>> possibility to try that, I don't think that it would work anyway...
> 
> Hello!
> 
>>
>> I'm a bit confused. "qcom/venus-4.4/venus.mdt" is the Sony signed FW?
>>
> 
> In my case it is, but this follows the generic firmware path as was done
> for all the other Venus firmwares, so my code is not pointing at Sony
> specific things, but just generic ones.
> 
> Every Qualcomm-powered consumer device (smartphones, tablets etc) have
> got a double sigcheck: one for qcom, one for OEM specific and most of
> the times the TZ is configured to accept only firmwares that also have
> the OEM signature.
> 
> This is not 

[PATCH v4 01/21] dt-bindings: clk: sunxi-ccu: Add compatible string for Allwinner H616

2021-01-25 Thread Andre Przywara
Signed-off-by: Andre Przywara 
Acked-by: Rob Herring 
Acked-by: Maxime Ripard 
---
 .../devicetree/bindings/clock/allwinner,sun4i-a10-ccu.yaml  | 2 ++
 1 file changed, 2 insertions(+)

diff --git 
a/Documentation/devicetree/bindings/clock/allwinner,sun4i-a10-ccu.yaml 
b/Documentation/devicetree/bindings/clock/allwinner,sun4i-a10-ccu.yaml
index 3b45344ed758..b7e891803bb4 100644
--- a/Documentation/devicetree/bindings/clock/allwinner,sun4i-a10-ccu.yaml
+++ b/Documentation/devicetree/bindings/clock/allwinner,sun4i-a10-ccu.yaml
@@ -41,6 +41,8 @@ properties:
   - allwinner,sun50i-h5-ccu
   - allwinner,sun50i-h6-ccu
   - allwinner,sun50i-h6-r-ccu
+  - allwinner,sun50i-h616-ccu
+  - allwinner,sun50i-h616-r-ccu
   - allwinner,suniv-f1c100s-ccu
   - nextthing,gr8-ccu
 
-- 
2.17.5



Re: [PATCH] Bluetooth: hci_h5: Set HCI_QUIRK_SIMULTANEOUS_DISCOVERY for btrtl

2021-01-25 Thread Marcel Holtmann
Hi Claire,

> Realtek Bluetooth controllers can do both LE scan and BR/EDR inquiry
> at once, need to set HCI_QUIRK_SIMULTANEOUS_DISCOVERY quirk.
> 
> Signed-off-by: Claire Chang 
> ---
> drivers/bluetooth/hci_h5.c | 5 +
> 1 file changed, 5 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel



[PATCH v4 15/21] phy: sun4i-usb: Rework HCI PHY (aka. "pmu_unk1") handling

2021-01-25 Thread Andre Przywara
As Icenowy pointed out, newer manuals (starting with H6) actually
document the register block at offset 0x800 as "HCI controller and PHY
interface", also describe the bits in our "PMU_UNK1" register.
Let's put proper names to those "unknown" variables and symbols.

While we are at it, generalise the existing code by allowing a bitmap
of bits to clear, to cover newer SoCs: The A100 and H616 use a different
bit for the SIDDQ control.

Signed-off-by: Andre Przywara 
Acked-by: Maxime Ripard 
---
 drivers/phy/allwinner/phy-sun4i-usb.c | 29 +++
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c 
b/drivers/phy/allwinner/phy-sun4i-usb.c
index 788dd5cdbb7d..539209fe3468 100644
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -43,7 +43,7 @@
 #define REG_PHYCTL_A33 0x10
 #define REG_PHY_OTGCTL 0x20
 
-#define REG_PMU_UNK1   0x10
+#define REG_HCI_PHY_CTL0x10
 
 #define PHYCTL_DATABIT(7)
 
@@ -115,9 +115,9 @@ struct sun4i_usb_phy_cfg {
int hsic_index;
enum sun4i_usb_phy_type type;
u32 disc_thresh;
+   u32 hci_phy_ctl_siddq;
u8 phyctl_offset;
bool dedicated_clocks;
-   bool enable_pmu_unk1;
bool phy0_dual_route;
int missing_phys;
 };
@@ -288,6 +288,12 @@ static int sun4i_usb_phy_init(struct phy *_phy)
return ret;
}
 
+   if (phy->pmu && data->cfg->hci_phy_ctl_siddq) {
+   val = readl(phy->pmu + REG_HCI_PHY_CTL);
+   val &= ~data->cfg->hci_phy_ctl_siddq;
+   writel(val, phy->pmu + REG_HCI_PHY_CTL);
+   }
+
if (data->cfg->type == sun8i_a83t_phy ||
data->cfg->type == sun50i_h6_phy) {
if (phy->index == 0) {
@@ -297,11 +303,6 @@ static int sun4i_usb_phy_init(struct phy *_phy)
writel(val, data->base + data->cfg->phyctl_offset);
}
} else {
-   if (phy->pmu && data->cfg->enable_pmu_unk1) {
-   val = readl(phy->pmu + REG_PMU_UNK1);
-   writel(val & ~2, phy->pmu + REG_PMU_UNK1);
-   }
-
/* Enable USB 45 Ohm resistor calibration */
if (phy->index == 0)
sun4i_usb_phy_write(phy, PHY_RES45_CAL_EN, 0x01, 1);
@@ -863,7 +864,6 @@ static const struct sun4i_usb_phy_cfg sun4i_a10_cfg = {
.disc_thresh = 3,
.phyctl_offset = REG_PHYCTL_A10,
.dedicated_clocks = false,
-   .enable_pmu_unk1 = false,
 };
 
 static const struct sun4i_usb_phy_cfg sun5i_a13_cfg = {
@@ -872,7 +872,6 @@ static const struct sun4i_usb_phy_cfg sun5i_a13_cfg = {
.disc_thresh = 2,
.phyctl_offset = REG_PHYCTL_A10,
.dedicated_clocks = false,
-   .enable_pmu_unk1 = false,
 };
 
 static const struct sun4i_usb_phy_cfg sun6i_a31_cfg = {
@@ -881,7 +880,6 @@ static const struct sun4i_usb_phy_cfg sun6i_a31_cfg = {
.disc_thresh = 3,
.phyctl_offset = REG_PHYCTL_A10,
.dedicated_clocks = true,
-   .enable_pmu_unk1 = false,
 };
 
 static const struct sun4i_usb_phy_cfg sun7i_a20_cfg = {
@@ -890,7 +888,6 @@ static const struct sun4i_usb_phy_cfg sun7i_a20_cfg = {
.disc_thresh = 2,
.phyctl_offset = REG_PHYCTL_A10,
.dedicated_clocks = false,
-   .enable_pmu_unk1 = false,
 };
 
 static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = {
@@ -899,7 +896,6 @@ static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = {
.disc_thresh = 3,
.phyctl_offset = REG_PHYCTL_A10,
.dedicated_clocks = true,
-   .enable_pmu_unk1 = false,
 };
 
 static const struct sun4i_usb_phy_cfg sun8i_a33_cfg = {
@@ -908,7 +904,6 @@ static const struct sun4i_usb_phy_cfg sun8i_a33_cfg = {
.disc_thresh = 3,
.phyctl_offset = REG_PHYCTL_A33,
.dedicated_clocks = true,
-   .enable_pmu_unk1 = false,
 };
 
 static const struct sun4i_usb_phy_cfg sun8i_a83t_cfg = {
@@ -925,7 +920,7 @@ static const struct sun4i_usb_phy_cfg sun8i_h3_cfg = {
.disc_thresh = 3,
.phyctl_offset = REG_PHYCTL_A33,
.dedicated_clocks = true,
-   .enable_pmu_unk1 = true,
+   .hci_phy_ctl_siddq = BIT(1),
.phy0_dual_route = true,
 };
 
@@ -935,7 +930,7 @@ static const struct sun4i_usb_phy_cfg sun8i_r40_cfg = {
.disc_thresh = 3,
.phyctl_offset = REG_PHYCTL_A33,
.dedicated_clocks = true,
-   .enable_pmu_unk1 = true,
+   .hci_phy_ctl_siddq = BIT(1),
.phy0_dual_route = true,
 };
 
@@ -945,7 +940,7 @@ static const struct sun4i_usb_phy_cfg sun8i_v3s_cfg = {
.disc_thresh = 3,
.phyctl_offset = REG_PHYCTL_A33,
.dedicated_clocks = true,
-   .enable_pmu_unk1 = true,
+   .hci_phy_ctl_siddq = BIT(1),
.phy0_dual_route = true,
 };
 
@@ -955,7 +950,7 @@ static const 

[PATCH v4 04/21] dt-bindings: mfd: axp20x: Add AXP305 compatible (plus optional IRQ)

2021-01-25 Thread Andre Przywara
The AXP305 PMIC used in AXP805 seems to be fully compatible to the
AXP805 PMIC, so add the proper chain of compatible strings.

Also at least on one board (Orangepi Zero2) there is no interrupt line
connected to the CPU, so make the "interrupts" property optional.

Signed-off-by: Andre Przywara 
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt 
b/Documentation/devicetree/bindings/mfd/axp20x.txt
index 4991a6415796..4fd748101e3c 100644
--- a/Documentation/devicetree/bindings/mfd/axp20x.txt
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -26,10 +26,10 @@ Required properties:
 * "x-powers,axp803"
 * "x-powers,axp806"
 * "x-powers,axp805", "x-powers,axp806"
+* "x-powers,axp803", "x-powers,axp805", "x-powers,axp806"
 * "x-powers,axp809"
 * "x-powers,axp813"
 - reg: The I2C slave address or RSB hardware address for the AXP chip
-- interrupts: SoC NMI / GPIO interrupt connected to the PMIC's IRQ pin
 - interrupt-controller: The PMIC has its own internal IRQs
 - #interrupt-cells: Should be set to 1
 
@@ -43,6 +43,7 @@ more information:
AXP20x/LDO3: software-based implementation
 
 Optional properties:
+- interrupts: SoC NMI / GPIO interrupt connected to the PMIC's IRQ pin
 - x-powers,dcdc-freq: defines the work frequency of DC-DC in KHz
  AXP152/20X: range:  750-1875, Default: 1.5 MHz
  AXP22X/8XX: range: 1800-4050, Default: 3   MHz
-- 
2.17.5



Re: [PATCH 2/3] dt-bindings: iio: Add cros ec proximity yaml doc

2021-01-25 Thread Rob Herring
On Sun, Jan 24, 2021 at 05:27:56PM +, Jonathan Cameron wrote:
> On Fri, 22 Jan 2021 14:54:42 -0800
> Stephen Boyd  wrote:
> 
> > Some cros ECs support a front proximity MKBP event via
> > 'EC_MKBP_FRONT_PROXIMITY'. Add a DT binding to document this feature via
> > a node that is a child of the main cros_ec device node. Devices that
> > have this ability will describe this in firmware.
> > 
> > Cc: Dmitry Torokhov 
> > Cc: Benson Leung 
> > Cc: Guenter Roeck 
> > Cc: Douglas Anderson 
> > Cc: Gwendal Grignou 
> > Cc: 
> > Cc: Rob Herring 
> > Signed-off-by: Stephen Boyd 
> > ---
> >  .../proximity/google,cros-ec-proximity.yaml   | 37 +++
> >  1 file changed, 37 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/iio/proximity/google,cros-ec-proximity.yaml
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/iio/proximity/google,cros-ec-proximity.yaml
> >  
> > b/Documentation/devicetree/bindings/iio/proximity/google,cros-ec-proximity.yaml
> > new file mode 100644
> > index ..c0a34bdfe4fd
> > --- /dev/null
> > +++ 
> > b/Documentation/devicetree/bindings/iio/proximity/google,cros-ec-proximity.yaml
> > @@ -0,0 +1,37 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +
> > +$id: 
> > http://devicetree.org/schemas/iio/proximity/google,cros-ec-proximity.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: ChromeOS EC MKBP Proximity Sensor
> > +
> > +maintainers:
> > +  - Stephen Boyd 
> > +  - Benson Leung 
> > +  - Enric Balletbo i Serra 
> > +
> > +description: |
> > +  Google's ChromeOS EC sometimes has the ability to detect user proximity.
> > +  This is implemented on the EC as near/far logic and exposed to the OS
> > +  via an MKBP switch bit.
> > +
> > +properties:
> > +  compatible:
> > +const: google,cros-ec-proximity
> > +
> > +  label:
> > +description: Name for proximity sensor
> > +
> > +required:
> > +  - compatible
> > +
> > +unevaluatedProperties: false

additionalProperties: false

> > +
> > +examples:
> > +  - |
> > +proximity {
> 
> Can we at least have the example making it clear this is a child of the
> cros_ec device?

Move this to the core Cros EC binding. The core binding needs to define 
'proximity' and reference this binding ($ref).

> 
> > +compatible = "google,cros-ec-proximity";
> > +label = "proximity-wifi-lte";
> > +};
> 


Re: [PATCH 2/3] media: videodev2.h: clarify v4l2_pix_format_mplane.sizeimage docs when to set to zero

2021-01-25 Thread Helen Koike



On 1/25/21 6:31 AM, Hans Verkuil wrote:
> On 14/01/2021 19:01, Helen Koike wrote:
>> sizeimage field should be set to zero for unused planes, even when
>> v4l2_pix_format_mplane.num_planes is smaller then the index of planes.
> 
> then -> than

Ack.

> 
>>
>> Signed-off-by: Helen Koike 
>>
>> ---
>>
>> I caught this with v4l2-compliance, which throws an error if we dirty
>> planes, even if invalid, so I would like to make it clear in the docs.
> 
> What is the error? And with which driver?

I was implementing conversions to/from Ext API, and I thought v4l2-compliance
wasn't happy if I didn't zero the other entries, but I'm trying to reproduce
it now by adding a non-zero value to sizeimage and I can't reproduce it, so
it was probably my mistake.
Please ignore this patch and sorry for the noise.

> 
> I wonder if this isn't a v4l2-compliance bug. And if we want this to be
> zeroed, then it wouldn't it be better to do that in the V4L2 core rather
> than bother drivers with this?
> 
>> ---
>>  include/uapi/linux/videodev2.h | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
>> index 79dbde3bcf8d..d9b7c9177605 100644
>> --- a/include/uapi/linux/videodev2.h
>> +++ b/include/uapi/linux/videodev2.h
>> @@ -2227,6 +2227,7 @@ struct v4l2_mpeg_vbi_fmt_ivtv {
>>   * struct v4l2_plane_pix_format - additional, per-plane format definition
>>   * @sizeimage:  maximum size in bytes required for data, for 
>> which
>>   *  this plane will be used
>> + *  Drivers should be set it zero for unused planes.
> 
> This sentence is a bit garbled.
> 
> You probably meant: Drivers must set this to zero for unused planes.
> 
> But it makes no sense to just zero this field. I would zero the whole struct
> contents for the unused planes.
> 
>>   * @bytesperline:   distance in bytes between the leftmost pixels in two
>>   *  adjacent lines
>>   */
>>
> 
> The API doesn't mention whether unused plane formats should be zeroed or not,
> but it does make sense that they are. I don't think that the userspace API
> should be changed (esp. since there are apparently already drivers that do
> not zero these unused plane formats), but it makes sense that the compliance
> test does verify this, and that the V4L2 core would zero unused plane formats.
> 
> I never like it when undefined values are allowed in an API, so it makes sense
> that this is done.


Ack.

Thanks
Helen


> 
> Regards,
> 
>   Hans
> 


[PATCH v4 08/21] soc: sunxi: sram: Add support for more than one EMAC clock

2021-01-25 Thread Andre Przywara
The Allwinner H616 adds a second EMAC clock register at offset 0x34, for
controlling the second EMAC in this chip.

Allow to extend the regmap in this case, to cover more than the current
4 bytes exported.

Signed-off-by: Andre Przywara 
---
 drivers/soc/sunxi/sunxi_sram.c | 31 +++
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c
index d4c7bd59429e..42833e33a96c 100644
--- a/drivers/soc/sunxi/sunxi_sram.c
+++ b/drivers/soc/sunxi/sunxi_sram.c
@@ -283,7 +283,7 @@ int sunxi_sram_release(struct device *dev)
 EXPORT_SYMBOL(sunxi_sram_release);
 
 struct sunxi_sramc_variant {
-   bool has_emac_clock;
+   int num_emac_clocks;
 };
 
 static const struct sunxi_sramc_variant sun4i_a10_sramc_variant = {
@@ -291,20 +291,31 @@ static const struct sunxi_sramc_variant 
sun4i_a10_sramc_variant = {
 };
 
 static const struct sunxi_sramc_variant sun8i_h3_sramc_variant = {
-   .has_emac_clock = true,
+   .num_emac_clocks = 1,
 };
 
 static const struct sunxi_sramc_variant sun50i_a64_sramc_variant = {
-   .has_emac_clock = true,
+   .num_emac_clocks = 1,
+};
+
+static const struct sunxi_sramc_variant sun50i_h616_sramc_variant = {
+   .num_emac_clocks = 2,
 };
 
 #define SUNXI_SRAM_EMAC_CLOCK_REG  0x30
 static bool sunxi_sram_regmap_accessible_reg(struct device *dev,
 unsigned int reg)
 {
-   if (reg == SUNXI_SRAM_EMAC_CLOCK_REG)
-   return true;
-   return false;
+   const struct sunxi_sramc_variant *variant;
+
+   variant = of_device_get_match_data(dev);
+
+   if (reg < SUNXI_SRAM_EMAC_CLOCK_REG)
+   return false;
+   if (reg > SUNXI_SRAM_EMAC_CLOCK_REG + variant->num_emac_clocks * 4)
+   return false;
+
+   return true;
 }
 
 static struct regmap_config sunxi_sram_emac_clock_regmap = {
@@ -312,7 +323,7 @@ static struct regmap_config sunxi_sram_emac_clock_regmap = {
.val_bits   = 32,
.reg_stride = 4,
/* last defined register */
-   .max_register   = SUNXI_SRAM_EMAC_CLOCK_REG,
+   .max_register   = SUNXI_SRAM_EMAC_CLOCK_REG + 4,
/* other devices have no business accessing other registers */
.readable_reg   = sunxi_sram_regmap_accessible_reg,
.writeable_reg  = sunxi_sram_regmap_accessible_reg,
@@ -343,7 +354,7 @@ static int sunxi_sram_probe(struct platform_device *pdev)
if (!d)
return -ENOMEM;
 
-   if (variant->has_emac_clock) {
+   if (variant->num_emac_clocks > 0) {
emac_clock = devm_regmap_init_mmio(>dev, base,
   
_sram_emac_clock_regmap);
 
@@ -387,6 +398,10 @@ static const struct of_device_id sunxi_sram_dt_match[] = {
.compatible = "allwinner,sun50i-h5-system-control",
.data = _a64_sramc_variant,
},
+   {
+   .compatible = "allwinner,sun50i-h616-system-control",
+   .data = _h616_sramc_variant,
+   },
{ },
 };
 MODULE_DEVICE_TABLE(of, sunxi_sram_dt_match);
-- 
2.17.5



[PATCH v8 2/2] iio: accel: Add support for the Bosch-Sensortec BMI088

2021-01-25 Thread Mike Looijmans
The BMI088 is a combined module with both accelerometer and gyroscope.
This adds the accelerometer driver support for the SPI interface.
The gyroscope part is already supported by the BMG160 driver.

Signed-off-by: Mike Looijmans 

---

Changes in v8:
include order asm/ after linux/
Suspend/resume redesigned, use runtime PM for both cases. Removed the
pm wrappers and let runtime PM handle power up/down. This also removed
the need for an internal mutex, thus reducing code further.

Changes in v7:
Change bmi088_accel to bmi088-accel
Order includes alphabetically
Suspend and disable on remove
Make bmi088_regmap_spi_{read|write} static

Changes in v6:
Hope you have good memory - v5 was almost a year ago now
Remove superfluous *val=0
Make sample_frequency selection into read_avail list

Changes in v5:
Add includes and forward defines in header
BIT(7) instead of 0x80
Reset already sets defaults, do not set them again
Remove now unused bmi088_accel_set_bw
Remove unused AXIS_MAX
Use MASK define for ODR setting
Explain buffer use and alignment
Split bmi088_accel_set_power_state into "on" and "off" parts
Cosmetic changes to improve readability

Changes in v4:
Remove unused #include directives
Remove unused #defines for event and irq
Replace (ret < 0) with (ret) for all regmap calls
Consistent checking of IO errors in probe and init
Removed #ifdef CONFIG_PM guard
Use bitops for set_frequency instead of loop with shift
s/__s16/s16/g
Remove excess blank lines
Don't return -EAGAIN in pm_runtime

Changes in v3:
Processed comments from Jonathan Cameron and Lars-Peter Clausen
implement runtime PM (tested by code tracing) and sleep
fix scale and offset factors for accel and temperature and
return raw values instead of pre-scaled ones
Use iio_device_{claim,release}_direct_mode
Remove unused code and structs
Use a cache-aligned buffer for bulk read
Configure and enable caching register values

Changes in v2:
Remove unused typedefs and variables
Fix error return when iio_device_register fails

 drivers/iio/accel/Kconfig |  18 +
 drivers/iio/accel/Makefile|   2 +
 drivers/iio/accel/bmi088-accel-core.c | 570 ++
 drivers/iio/accel/bmi088-accel-spi.c  |  83 
 drivers/iio/accel/bmi088-accel.h  |  18 +
 5 files changed, 691 insertions(+)
 create mode 100644 drivers/iio/accel/bmi088-accel-core.c
 create mode 100644 drivers/iio/accel/bmi088-accel-spi.c
 create mode 100644 drivers/iio/accel/bmi088-accel.h

diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
index 2e0c62c39155..cceda3cecbcf 100644
--- a/drivers/iio/accel/Kconfig
+++ b/drivers/iio/accel/Kconfig
@@ -157,6 +157,24 @@ config BMC150_ACCEL_SPI
tristate
select REGMAP_SPI
 
+config BMI088_ACCEL
+   tristate "Bosch BMI088 Accelerometer Driver"
+   depends on SPI
+   select IIO_BUFFER
+   select IIO_TRIGGERED_BUFFER
+   select REGMAP
+   select BMI088_ACCEL_SPI
+   help
+ Say yes here to build support for the Bosch BMI088 accelerometer.
+
+ This is a combo module with both accelerometer and gyroscope. This
+ driver only implements the accelerometer part, which has its own
+ address and register map. BMG160 provides the gyroscope driver.
+
+config BMI088_ACCEL_SPI
+   tristate
+   select REGMAP_SPI
+
 config DA280
tristate "MiraMEMS DA280 3-axis 14-bit digital accelerometer driver"
depends on I2C
diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile
index 4f6c1ebe13b0..32cd1342a31a 100644
--- a/drivers/iio/accel/Makefile
+++ b/drivers/iio/accel/Makefile
@@ -20,6 +20,8 @@ obj-$(CONFIG_BMA400_SPI) += bma400_spi.o
 obj-$(CONFIG_BMC150_ACCEL) += bmc150-accel-core.o
 obj-$(CONFIG_BMC150_ACCEL_I2C) += bmc150-accel-i2c.o
 obj-$(CONFIG_BMC150_ACCEL_SPI) += bmc150-accel-spi.o
+obj-$(CONFIG_BMI088_ACCEL) += bmi088-accel-core.o
+obj-$(CONFIG_BMI088_ACCEL_SPI) += bmi088-accel-spi.o
 obj-$(CONFIG_DA280)+= da280.o
 obj-$(CONFIG_DA311)+= da311.o
 obj-$(CONFIG_DMARD06)  += dmard06.o
diff --git a/drivers/iio/accel/bmi088-accel-core.c 
b/drivers/iio/accel/bmi088-accel-core.c
new file mode 100644
index ..f86010a3cda3
--- /dev/null
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -0,0 +1,570 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * 3-axis accelerometer driver supporting following Bosch-Sensortec chips:
+ *  - BMI088
+ *
+ * Copyright (c) 2018-2021, Topic Embedded Products
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "bmi088-accel.h"
+
+#define BMI088_ACCEL_REG_CHIP_ID   0x00
+#define BMI088_ACCEL_REG_ERROR 0x02
+
+#define BMI088_ACCEL_REG_INT_STATUS0x1D
+#define BMI088_ACCEL_INT_STATUS_BIT_DRDY   BIT(7)
+
+#define BMI088_ACCEL_REG_RESET 0x7E
+#define BMI088_ACCEL_RESET_VAL 0xB6

[PATCH v8 1/2] dt-bindings: iio: accel: Add bmi088 accelerometer bindings

2021-01-25 Thread Mike Looijmans
This adds the device-tree bindings for the Bosch Sensortec BMI088 IMU,
the accelerometer part.

Signed-off-by: Mike Looijmans 

---

Changes in v8:
Add spi-max-frequency: true

Changes in v7:
Add additionalProperties
Change bmi088_accel to bmi088-accel
Add interrupt-names and adjust description

Changes in v6:
I't been almost a year since the last commit, sorry...
Fixed the yaml errors
Add interrupt, vdd and vddio properties

Changes in v5:
submit together with driver code as patch series

Changes in v2:
convert to yaml format

 .../bindings/iio/accel/bosch,bmi088.yaml  | 68 +++
 1 file changed, 68 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/iio/accel/bosch,bmi088.yaml

diff --git a/Documentation/devicetree/bindings/iio/accel/bosch,bmi088.yaml 
b/Documentation/devicetree/bindings/iio/accel/bosch,bmi088.yaml
new file mode 100644
index ..911a1ae9c83f
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/accel/bosch,bmi088.yaml
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/accel/bosch,bmi088.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Bosch BMI088 IMU accelerometer part
+
+maintainers:
+  - Mike Looijmans 
+
+description: |
+  Acceleration part of the IMU sensor with an SPI interface
+  Specifications about the sensor can be found at:
+
https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmi088-ds001.pdf
+
+properties:
+  compatible:
+enum:
+  - bosch,bmi088-accel
+
+  reg:
+maxItems: 1
+
+  spi-max-frequency: true
+
+  vdd-supply: true
+
+  vddio-supply: true
+
+  interrupts:
+minItems: 1
+maxItems: 2
+description: |
+  Type should be either IRQ_TYPE_LEVEL_HIGH or IRQ_TYPE_LEVEL_LOW.
+  Two configurable interrupt lines exist.
+
+  interrupt-names:
+description: Specify which interrupt line is in use.
+items:
+  enum:
+- INT1
+- INT2
+minItems: 1
+maxItems: 2
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+spi {
+  #address-cells = <1>;
+  #size-cells = <0>;
+  bmi088-accel@1 {
+compatible = "bosch,bmi088-accel";
+reg = <1>;
+spi-max-frequency = <1000>;
+interrupt-parent = <>;
+interrupts = <19 IRQ_TYPE_LEVEL_LOW>;
+interrupt-names = "INT2";
+  };
+};
+...
-- 
2.17.1



Re: [PATCH] [net-next] ipa: add remoteproc dependency

2021-01-25 Thread Bjorn Andersson
On Mon 25 Jan 05:35 CST 2021, Arnd Bergmann wrote:

> From: Arnd Bergmann 
> 
> Compile-testing without CONFIG_REMOTEPROC results in a build failure:
> 
> >>> referenced by ipa_main.c
> >>>   net/ipa/ipa_main.o:(ipa_probe) in archive drivers/built-in.a
> ld.lld: error: undefined symbol: rproc_put
> >>> referenced by ipa_main.c
> >>>   net/ipa/ipa_main.o:(ipa_probe) in archive drivers/built-in.a
> >>> referenced by ipa_main.c
> >>>   net/ipa/ipa_main.o:(ipa_remove) in archive 
> >>> drivers/built-in.a
> 
> Add a new dependency to avoid this.
> 

Afaict this should be addressed by:

86fdf1fc60e9 ("net: ipa: remove a remoteproc dependency")

which is present in linux-next.

Regards,
Bjorn

> Fixes: 38a4066f593c ("net: ipa: support COMPILE_TEST")
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/net/ipa/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ipa/Kconfig b/drivers/net/ipa/Kconfig
> index b68f1289b89e..aa1c0ae3cf01 100644
> --- a/drivers/net/ipa/Kconfig
> +++ b/drivers/net/ipa/Kconfig
> @@ -3,6 +3,7 @@ config QCOM_IPA
>   depends on 64BIT && NET && QCOM_SMEM
>   depends on ARCH_QCOM || COMPILE_TEST
>   depends on QCOM_RPROC_COMMON || (QCOM_RPROC_COMMON=n && COMPILE_TEST)
> + depends on REMOTEPROC
>   select QCOM_MDT_LOADER if ARCH_QCOM
>   select QCOM_QMI_HELPERS
>   help
> -- 
> 2.29.2
> 


Re: [PATCH v2 4/7] rbtree, perf: Use new rbtree helpers

2021-01-25 Thread Tejun Heo
On Mon, Jan 25, 2021 at 04:09:57PM +0100, Peter Zijlstra wrote:
> Reduce rbtree boiler plate by using the new helpers.
> 
> One noteworthy change is unification of the various (partial) compare
> functions. We construct a subtree match by forcing the sub-order to
> always match, see __group_cmp().
> 
> Due to 'const' we had to touch cgroup_id().
> 
> Cc: Tejun Heo 
> Signed-off-by: Peter Zijlstra (Intel) 

Acked-by: Tejun Heo 

Thanks.

-- 
tejun


[PATCH v4 2/2] net: sfp: add mode quirk for GPON module Ubiquiti U-Fiber Instant

2021-01-25 Thread Pali Rohár
The Ubiquiti U-Fiber Instant SFP GPON module has nonsensical information
stored in its EEPROM. It claims to support all transceiver types including
10G Ethernet. Clear all claimed modes and set only 1000baseX_Full, which is
the only one supported.

This module has also phys_id set to SFF, and the SFP subsystem currently
does not allow to use SFP modules detected as SFFs. Add exception for this
module so it can be detected as supported.

This change finally allows to detect and use SFP GPON module Ubiquiti
U-Fiber Instant on Linux system.

EEPROM content of this SFP module is (where XX is serial number):

00: 02 04 0b ff ff ff ff ff ff ff ff 03 0c 00 14 c8?????.??
10: 00 00 00 00 55 42 4e 54 20 20 20 20 20 20 20 20UBNT
20: 20 20 20 20 00 18 e8 29 55 46 2d 49 4e 53 54 41.??)UF-INSTA
30: 4e 54 20 20 20 20 20 20 34 20 20 20 05 1e 00 36NT  4   ??.6
40: 00 06 00 00 55 42 4e 54 XX XX XX XX XX XX XX XX.?..UBNT
50: 20 20 20 20 31 34 30 31 32 33 20 20 60 80 02 41140123  `??A

Signed-off-by: Pali Rohár 

---
Changes in v4:
* Rewritten the commit message by Marek's suggestion

Changes in v3:
* no change

Changes in v2:
* add this module also into sfp_module_supported() function
---
 drivers/net/phy/sfp-bus.c | 15 +++
 drivers/net/phy/sfp.c | 17 +++--
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c
index 20b91f5dfc6e..4cf874fb5c5b 100644
--- a/drivers/net/phy/sfp-bus.c
+++ b/drivers/net/phy/sfp-bus.c
@@ -44,6 +44,17 @@ static void sfp_quirk_2500basex(const struct sfp_eeprom_id 
*id,
phylink_set(modes, 2500baseX_Full);
 }
 
+static void sfp_quirk_ubnt_uf_instant(const struct sfp_eeprom_id *id,
+ unsigned long *modes)
+{
+   /* Ubiquiti U-Fiber Instant module claims that support all transceiver
+* types including 10G Ethernet which is not truth. So clear all claimed
+* modes and set only one mode which module supports: 1000baseX_Full.
+*/
+   phylink_zero(modes);
+   phylink_set(modes, 1000baseX_Full);
+}
+
 static const struct sfp_quirk sfp_quirks[] = {
{
// Alcatel Lucent G-010S-P can operate at 2500base-X, but
@@ -63,6 +74,10 @@ static const struct sfp_quirk sfp_quirks[] = {
.vendor = "HUAWEI",
.part = "MA5671A",
.modes = sfp_quirk_2500basex,
+   }, {
+   .vendor = "UBNT",
+   .part = "UF-INSTANT",
+   .modes = sfp_quirk_ubnt_uf_instant,
},
 };
 
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index f2b5e467a800..7a680b5177f5 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -273,8 +273,21 @@ static const struct sff_data sff_data = {
 
 static bool sfp_module_supported(const struct sfp_eeprom_id *id)
 {
-   return id->base.phys_id == SFF8024_ID_SFP &&
-  id->base.phys_ext_id == SFP_PHYS_EXT_ID_SFP;
+   if (id->base.phys_id == SFF8024_ID_SFP &&
+   id->base.phys_ext_id == SFP_PHYS_EXT_ID_SFP)
+   return true;
+
+   /* SFP GPON module Ubiquiti U-Fiber Instant has in its EEPROM stored
+* phys id SFF instead of SFP. Therefore mark this module explicitly
+* as supported based on vendor name and pn match.
+*/
+   if (id->base.phys_id == SFF8024_ID_SFF_8472 &&
+   id->base.phys_ext_id == SFP_PHYS_EXT_ID_SFP &&
+   !memcmp(id->base.vendor_name, "UBNT", 16) &&
+   !memcmp(id->base.vendor_pn, "UF-INSTANT  ", 16))
+   return true;
+
+   return false;
 }
 
 static const struct sff_data sfp_data = {
-- 
2.20.1



[PATCH v4 16/23] powerpc/32: Always save non volatile GPRs at syscall entry

2021-01-25 Thread Christophe Leroy
In preparation for porting syscall entry/exit to C, inconditionally
save non volatile general purpose registers.

Commit 965dd3ad3076 ("powerpc/64/syscall: Remove non-volatile GPR save
optimisation") provides detailed explanation.

This increases the number of cycles by 24 cycles on 8xx with
null_syscall benchmark (280 => 304 cycles)

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/entry_32.S   | 46 +---
 arch/powerpc/kernel/head_32.h|  2 +-
 arch/powerpc/kernel/head_booke.h |  2 +-
 arch/powerpc/kernel/syscalls/syscall.tbl | 20 +++
 4 files changed, 8 insertions(+), 62 deletions(-)

diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index b1e36602c013..97dc28a68465 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -351,6 +351,7 @@ trace_syscall_entry_irq_off:
 
.globl  transfer_to_syscall
 transfer_to_syscall:
+   SAVE_NVGPRS(r1)
 #ifdef CONFIG_PPC_BOOK3S_32
kuep_lock r11, r12
 #endif
@@ -614,51 +615,6 @@ ret_from_kernel_syscall:
 #endif
 _ASM_NOKPROBE_SYMBOL(ret_from_kernel_syscall)
 
-/*
- * The fork/clone functions need to copy the full register set into
- * the child process. Therefore we need to save all the nonvolatile
- * registers (r13 - r31) before calling the C code.
- */
-   .globl  ppc_fork
-ppc_fork:
-   SAVE_NVGPRS(r1)
-   lwz r0,_TRAP(r1)
-   rlwinm  r0,r0,0,0,30/* clear LSB to indicate full */
-   stw r0,_TRAP(r1)/* register set saved */
-   b   sys_fork
-
-   .globl  ppc_vfork
-ppc_vfork:
-   SAVE_NVGPRS(r1)
-   lwz r0,_TRAP(r1)
-   rlwinm  r0,r0,0,0,30/* clear LSB to indicate full */
-   stw r0,_TRAP(r1)/* register set saved */
-   b   sys_vfork
-
-   .globl  ppc_clone
-ppc_clone:
-   SAVE_NVGPRS(r1)
-   lwz r0,_TRAP(r1)
-   rlwinm  r0,r0,0,0,30/* clear LSB to indicate full */
-   stw r0,_TRAP(r1)/* register set saved */
-   b   sys_clone
-
-   .globl  ppc_clone3
-ppc_clone3:
-   SAVE_NVGPRS(r1)
-   lwz r0,_TRAP(r1)
-   rlwinm  r0,r0,0,0,30/* clear LSB to indicate full */
-   stw r0,_TRAP(r1)/* register set saved */
-   b   sys_clone3
-
-   .globl  ppc_swapcontext
-ppc_swapcontext:
-   SAVE_NVGPRS(r1)
-   lwz r0,_TRAP(r1)
-   rlwinm  r0,r0,0,0,30/* clear LSB to indicate full */
-   stw r0,_TRAP(r1)/* register set saved */
-   b   sys_swapcontext
-
 /*
  * Top-level page fault handling.
  * This is in assembler because if do_page_fault tells us that
diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h
index 24dc326e0d56..7b12736ec546 100644
--- a/arch/powerpc/kernel/head_32.h
+++ b/arch/powerpc/kernel/head_32.h
@@ -148,7 +148,7 @@
stw r2,GPR2(r11)
addir10,r10,STACK_FRAME_REGS_MARKER@l
stw r9,_MSR(r11)
-   li  r2, \trapno + 1
+   li  r2, \trapno
stw r10,8(r11)
stw r2,_TRAP(r11)
SAVE_GPR(0, r11)
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index b3c502c503a0..626e716576ce 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -124,7 +124,7 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV)
stw r2,GPR2(r11)
addir12, r12, STACK_FRAME_REGS_MARKER@l
stw r9,_MSR(r11)
-   li  r2, \trapno + 1
+   li  r2, \trapno
stw r12, 8(r11)
stw r2,_TRAP(r11)
SAVE_GPR(0, r11)
diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl 
b/arch/powerpc/kernel/syscalls/syscall.tbl
index f744eb5cba88..96b2157f0371 100644
--- a/arch/powerpc/kernel/syscalls/syscall.tbl
+++ b/arch/powerpc/kernel/syscalls/syscall.tbl
@@ -9,9 +9,7 @@
 #
 0  nospu   restart_syscall sys_restart_syscall
 1  nospu   exitsys_exit
-2  32  forkppc_fork
sys_fork
-2  64  forksys_fork
-2  spu forksys_ni_syscall
+2  nospu   forksys_fork
 3  common  readsys_read
 4  common  write   sys_write
 5  common  opensys_open
compat_sys_open
@@ -160,9 +158,7 @@
 11932  sigreturn   sys_sigreturn   
compat_sys_sigreturn
 11964  sigreturn   sys_ni_syscall
 119spu sigreturn   sys_ni_syscall
-12032  clone   ppc_clone   
sys_clone
-12064  clone   sys_clone
-120spu clone 

[PATCH v4 09/23] powerpc/irq: Rework helpers that manipulate MSR[EE/RI]

2021-01-25 Thread Christophe Leroy
In preparation of porting PPC32 to C syscall entry/exit,
rewrite the following helpers as static inline functions and
add support for PPC32 in them:
__hard_irq_enable()
__hard_irq_disable()
__hard_EE_RI_disable()
__hard_RI_enable()

Then use them in PPC32 version of arch_local_irq_disable()
and arch_local_irq_enable() to avoid code duplication.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/include/asm/hw_irq.h | 75 +--
 arch/powerpc/include/asm/reg.h|  1 +
 2 files changed, 52 insertions(+), 24 deletions(-)

diff --git a/arch/powerpc/include/asm/hw_irq.h 
b/arch/powerpc/include/asm/hw_irq.h
index ed0c3b049dfd..4739f61e632c 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -50,6 +50,55 @@
 
 #ifndef __ASSEMBLY__
 
+static inline void __hard_irq_enable(void)
+{
+   if (IS_ENABLED(CONFIG_BOOKE) || IS_ENABLED(CONFIG_40x))
+   wrtee(MSR_EE);
+   else if (IS_ENABLED(CONFIG_PPC_8xx))
+   wrtspr(SPRN_EIE);
+   else if (IS_ENABLED(CONFIG_PPC_BOOK3S_64))
+   __mtmsrd(MSR_EE | MSR_RI, 1);
+   else
+   mtmsr(mfmsr() | MSR_EE);
+}
+
+static inline void __hard_irq_disable(void)
+{
+   if (IS_ENABLED(CONFIG_BOOKE) || IS_ENABLED(CONFIG_40x))
+   wrtee(0);
+   else if (IS_ENABLED(CONFIG_PPC_8xx))
+   wrtspr(SPRN_EID);
+   else if (IS_ENABLED(CONFIG_PPC_BOOK3S_64))
+   __mtmsrd(MSR_RI, 1);
+   else
+   mtmsr(mfmsr() & ~MSR_EE);
+}
+
+static inline void __hard_EE_RI_disable(void)
+{
+   if (IS_ENABLED(CONFIG_BOOKE) || IS_ENABLED(CONFIG_40x))
+   wrtee(0);
+   else if (IS_ENABLED(CONFIG_PPC_8xx))
+   wrtspr(SPRN_NRI);
+   else if (IS_ENABLED(CONFIG_PPC_BOOK3S_64))
+   __mtmsrd(0, 1);
+   else
+   mtmsr(mfmsr() & ~(MSR_EE | MSR_RI));
+}
+
+static inline void __hard_RI_enable(void)
+{
+   if (IS_ENABLED(CONFIG_BOOKE) || IS_ENABLED(CONFIG_40x))
+   return;
+
+   if (IS_ENABLED(CONFIG_PPC_8xx))
+   wrtspr(SPRN_EID);
+   else if (IS_ENABLED(CONFIG_PPC_BOOK3S_64))
+   __mtmsrd(MSR_RI, 1);
+   else
+   mtmsr(mfmsr() | MSR_RI);
+}
+
 #ifdef CONFIG_PPC64
 #include 
 
@@ -212,18 +261,6 @@ static inline bool arch_irqs_disabled(void)
 
 #endif /* CONFIG_PPC_BOOK3S */
 
-#ifdef CONFIG_PPC_BOOK3E
-#define __hard_irq_enable()wrtee(MSR_EE)
-#define __hard_irq_disable()   wrtee(0)
-#define __hard_EE_RI_disable() wrtee(0)
-#define __hard_RI_enable() do { } while (0)
-#else
-#define __hard_irq_enable()__mtmsrd(MSR_EE|MSR_RI, 1)
-#define __hard_irq_disable()   __mtmsrd(MSR_RI, 1)
-#define __hard_EE_RI_disable() __mtmsrd(0, 1)
-#define __hard_RI_enable() __mtmsrd(MSR_RI, 1)
-#endif
-
 #define hard_irq_disable() do {\
unsigned long flags;\
__hard_irq_disable();   \
@@ -322,22 +359,12 @@ static inline unsigned long arch_local_irq_save(void)
 
 static inline void arch_local_irq_disable(void)
 {
-   if (IS_ENABLED(CONFIG_BOOKE))
-   wrtee(0);
-   else if (IS_ENABLED(CONFIG_PPC_8xx))
-   wrtspr(SPRN_EID);
-   else
-   mtmsr(mfmsr() & ~MSR_EE);
+   __hard_irq_disable();
 }
 
 static inline void arch_local_irq_enable(void)
 {
-   if (IS_ENABLED(CONFIG_BOOKE))
-   wrtee(MSR_EE);
-   else if (IS_ENABLED(CONFIG_PPC_8xx))
-   wrtspr(SPRN_EIE);
-   else
-   mtmsr(mfmsr() | MSR_EE);
+   __hard_irq_enable();
 }
 
 static inline bool arch_irqs_disabled_flags(unsigned long flags)
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index e40a921d78f9..d05dca30604d 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -1375,6 +1375,7 @@
 #define mtmsr(v)   asm volatile("mtmsr %0" : \
 : "r" ((unsigned long)(v)) \
 : "memory")
+#define __mtmsrd(v, l) BUILD_BUG()
 #define __MTMSR"mtmsr"
 #endif
 
-- 
2.25.0



[PATCH v4 10/23] powerpc/irq: Add stub irq_soft_mask_return() for PPC32

2021-01-25 Thread Christophe Leroy
To allow building syscall_64.c smoothly on PPC32, add stub version
of irq_soft_mask_return().

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/include/asm/hw_irq.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/include/asm/hw_irq.h 
b/arch/powerpc/include/asm/hw_irq.h
index 4739f61e632c..56a98936a6a9 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -330,6 +330,11 @@ static inline void irq_soft_mask_regs_set_state(struct 
pt_regs *regs, unsigned l
 }
 #else /* CONFIG_PPC64 */
 
+static inline notrace unsigned long irq_soft_mask_return(void)
+{
+   return 0;
+}
+
 static inline unsigned long arch_local_save_flags(void)
 {
return mfmsr();
-- 
2.25.0



[PATCH v4 08/23] powerpc/irq: Add helper to set regs->softe

2021-01-25 Thread Christophe Leroy
regs->softe doesn't exist on PPC32.

Add irq_soft_mask_regs_set_state() helper to set regs->softe.
This helper will void on PPC32.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/include/asm/hw_irq.h | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/hw_irq.h 
b/arch/powerpc/include/asm/hw_irq.h
index 614957f74cee..ed0c3b049dfd 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -38,6 +38,8 @@
 #define PACA_IRQ_MUST_HARD_MASK(PACA_IRQ_EE)
 #endif
 
+#endif /* CONFIG_PPC64 */
+
 /*
  * flags for paca->irq_soft_mask
  */
@@ -46,8 +48,6 @@
 #define IRQS_PMI_DISABLED  2
 #define IRQS_ALL_DISABLED  (IRQS_DISABLED | IRQS_PMI_DISABLED)
 
-#endif /* CONFIG_PPC64 */
-
 #ifndef __ASSEMBLY__
 
 #ifdef CONFIG_PPC64
@@ -287,6 +287,10 @@ extern void irq_set_pending_from_srr1(unsigned long srr1);
 
 extern void force_external_irq_replay(void);
 
+static inline void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned 
long val)
+{
+   regs->softe = val;
+}
 #else /* CONFIG_PPC64 */
 
 static inline unsigned long arch_local_save_flags(void)
@@ -355,6 +359,9 @@ static inline bool arch_irq_disabled_regs(struct pt_regs 
*regs)
 
 static inline void may_hard_irq_enable(void) { }
 
+static inline void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned 
long val)
+{
+}
 #endif /* CONFIG_PPC64 */
 
 #define ARCH_IRQ_INIT_FLAGSIRQ_NOREQUEST
-- 
2.25.0



[PATCH v4 15/23] powerpc/syscall: Change condition to check MSR_RI

2021-01-25 Thread Christophe Leroy
In system_call_exception(), MSR_RI also needs to be checked on 8xx.
Only booke and 40x doesn't have MSR_RI.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/syscall.c b/arch/powerpc/kernel/syscall.c
index b66cfcbcb755..a3510fa4e641 100644
--- a/arch/powerpc/kernel/syscall.c
+++ b/arch/powerpc/kernel/syscall.c
@@ -39,7 +39,7 @@ notrace long system_call_exception(long r3, long r4, long r5,
 
trace_hardirqs_off(); /* finish reconciling */
 
-   if (IS_ENABLED(CONFIG_PPC_BOOK3S))
+   if (!IS_ENABLED(CONFIG_BOOKE) && !IS_ENABLED(CONFIG_40x))
BUG_ON(!(regs->msr & MSR_RI));
BUG_ON(!(regs->msr & MSR_PR));
BUG_ON(!FULL_REGS(regs));
-- 
2.25.0



[PATCH v4 13/23] powerpc/syscall: Use is_compat_task()

2021-01-25 Thread Christophe Leroy
Instead of hard comparing task flags with _TIF_32BIT, use
is_compat_task(). The advantage is that it returns 0 on PPC32
allthough _TIF_32BIT is always set.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/syscall.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/syscall.c b/arch/powerpc/kernel/syscall.c
index bf9bf4b5bc41..cb415170b8f2 100644
--- a/arch/powerpc/kernel/syscall.c
+++ b/arch/powerpc/kernel/syscall.c
@@ -2,6 +2,8 @@
 
 #include 
 #include 
+#include 
+
 #include 
 #include 
 #include 
@@ -116,7 +118,7 @@ notrace long system_call_exception(long r3, long r4, long 
r5,
/* May be faster to do array_index_nospec? */
barrier_nospec();
 
-   if (unlikely(is_32bit_task())) {
+   if (unlikely(is_compat_task())) {
f = (void *)compat_sys_call_table[r0];
 
r3 &= 0xULL;
-- 
2.25.0



[PATCH v4 14/23] powerpc/syscall: Save r3 in regs->orig_r3

2021-01-25 Thread Christophe Leroy
Save r3 in regs->orig_r3 in system_call_exception()

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/entry_64.S | 1 -
 arch/powerpc/kernel/syscall.c  | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index aa1af139d947..a562a4240aa6 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -278,7 +278,6 @@ END_BTB_FLUSH_SECTION
std r10,_LINK(r1)
std r11,_TRAP(r1)
std r12,_CCR(r1)
-   std r3,ORIG_GPR3(r1)
addir10,r1,STACK_FRAME_OVERHEAD
ld  r11,exception_marker@toc(r2)
std r11,-16(r10)/* "regshere" marker */
diff --git a/arch/powerpc/kernel/syscall.c b/arch/powerpc/kernel/syscall.c
index cb415170b8f2..b66cfcbcb755 100644
--- a/arch/powerpc/kernel/syscall.c
+++ b/arch/powerpc/kernel/syscall.c
@@ -29,6 +29,8 @@ notrace long system_call_exception(long r3, long r4, long r5,
 {
syscall_fn f;
 
+   regs->orig_gpr3 = r3;
+
if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG))
BUG_ON(irq_soft_mask_return() != IRQS_ALL_DISABLED);
 
-- 
2.25.0



[PATCH] kgdb: rectify kernel-doc for kgdb_unregister_io_module()

2021-01-25 Thread Lukas Bulwahn
The command 'find ./kernel/debug/ | xargs ./scripts/kernel-doc -none'
reported a typo in the kernel-doc of kgdb_unregister_io_module().

Rectify the kernel-doc, such that no issues remain for ./kernel/debug/.

Signed-off-by: Lukas Bulwahn 
---
applies cleanly on v5.11-rc5 and next-20210122

Jason, Daniel, please pick this minor typo fixup.

 kernel/debug/debug_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
index af6e8b4fb359..7f22c1c0ffe8 100644
--- a/kernel/debug/debug_core.c
+++ b/kernel/debug/debug_core.c
@@ -1166,7 +1166,7 @@ int kgdb_register_io_module(struct kgdb_io 
*new_dbg_io_ops)
 EXPORT_SYMBOL_GPL(kgdb_register_io_module);
 
 /**
- * kkgdb_unregister_io_module - unregister KGDB IO module
+ * kgdb_unregister_io_module - unregister KGDB IO module
  * @old_dbg_io_ops: the io ops vector
  *
  * Unregister it with the KGDB core.
-- 
2.17.1



Re: [PATCH v2 09/17] mfd: Support for ROHM BD71815 PMIC core

2021-01-25 Thread Matti Vaittinen
Hello Lee,

Thanks again for the review!

On Mon, 2021-01-25 at 14:10 +, Lee Jones wrote:
> On Tue, 19 Jan 2021, Matti Vaittinen wrote:
> 
> > Add core support for ROHM BD71815 Power Management IC.
> > 
> > The IC integrates regulators, a battery charger with a coulomb
> > counter,
> > a real-time clock (RTC), clock gate and general-purpose outputs
> > (GPO).
> > 
> > Signed-off-by: Matti Vaittinen 
> > ---
> > Changes since v1:
> >   - Used BIT() for better readability
> >   - removed some unused definitions
> > 
> >  drivers/mfd/Kconfig  |  15 +-
> >  drivers/mfd/rohm-bd71828.c   | 416 +--
> >  include/linux/mfd/rohm-bd71815.h | 561
> > +++
> >  include/linux/mfd/rohm-bd71828.h |   3 +
> >  4 files changed, 952 insertions(+), 43 deletions(-)
> >  create mode 100644 include/linux/mfd/rohm-bd71815.h
> > 
> > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> > index bdfce7b15621..59bfacb91898 100644
> > --- a/drivers/mfd/Kconfig
> > +++ b/drivers/mfd/Kconfig
> > @@ -1984,19 +1984,20 @@ config MFD_ROHM_BD70528
> >   charger.
> >  
> >  config MFD_ROHM_BD71828
> > -   tristate "ROHM BD71828 Power Management IC"
> > +   tristate "ROHM BD71828 and BD71815 Power Management IC"
> > depends on I2C=y
> > depends on OF
> > select REGMAP_I2C
> > select REGMAP_IRQ
> > select MFD_CORE
> > help
> > - Select this option to get support for the ROHM BD71828 Power
> > - Management IC. BD71828GW is a single-chip power management IC
> > for
> > - battery-powered portable devices. The IC integrates 7 buck
> > - converters, 7 LDOs, and a 1500 mA single-cell linear charger.
> > - Also included is a Coulomb counter, a real-time clock (RTC),
> > and
> > - a 32.768 kHz clock gate.
> > + Select this option to get support for the ROHM BD71828 and
> > BD71815
> > + Power Management ICs. BD71828GW and BD71815AGW are single-
> > chip power
> > + management ICs mainly for battery-powered portable devices.
> > + The BD71828 integrates 7 buck converters and 7 LDOs. The
> > BD71815
> > + has 5 bucks, 7 LDOs, and a boost for driving LEDs. Both ICs
> > provide
> > + also a single-cell linear charger, a Coulomb counter, a real-
> > time
> > + clock (RTC), GPIOs and a 32.768 kHz clock gate.
> >  
> >  config MFD_STM32_LPTIMER
> > tristate "Support for STM32 Low-Power Timer"
> > diff --git a/drivers/mfd/rohm-bd71828.c b/drivers/mfd/rohm-
> > bd71828.c
> > index 210261d026f2..28b82477ce4c 100644
> > --- a/drivers/mfd/rohm-bd71828.c
> > +++ b/drivers/mfd/rohm-bd71828.c
> > @@ -2,7 +2,7 @@
> >  //
> >  // Copyright (C) 2019 ROHM Semiconductors
> >  //
> > -// ROHM BD71828 PMIC driver
> > +// ROHM BD71828/BD71815 PMIC driver
> >  
> >  #include 
> >  #include 
> > @@ -11,7 +11,9 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -29,12 +31,102 @@ static struct gpio_keys_platform_data
> > bd71828_powerkey_data = {
> > .name = "bd71828-pwrkey",
> >  };
> >  
> > -static const struct resource rtc_irqs[] = {
> > +static const struct resource bd71815_rtc_irqs[] = {
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_RTC0, "bd71815-rtc-alm-0"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_RTC1, "bd71815-rtc-alm-1"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_RTC2, "bd71815-rtc-alm-2"),
> > +};
> > +
> > +static const struct resource bd71828_rtc_irqs[] = {
> > DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC0, "bd71828-rtc-alm-0"),
> > DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC1, "bd71828-rtc-alm-1"),
> > DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC2, "bd71828-rtc-alm-2"),
> >  };
> >  
> > +static struct resource bd71815_power_irqs[] = {
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_RMV, "bd71815-dcin-rmv"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_CLPS_OUT, "bd71815-clps-out"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_CLPS_IN, "bd71815-clps-in"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_OVP_RES, "bd71815-dcin-
> > ovp-res"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_OVP_DET, "bd71815-dcin-
> > ovp-det"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_MON_RES, "bd71815-dcin-
> > mon-res"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_MON_DET, "bd71815-dcin-
> > mon-det"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_UV_RES, "bd71815-vsys-uv-
> > res"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_UV_DET, "bd71815-vsys-uv-
> > det"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_LOW_RES, "bd71815-vsys-
> > low-res"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_LOW_DET, "bd71815-vsys-
> > low-det"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_MON_RES, "bd71815-vsys-
> > mon-res"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_VSYS_MON_RES, "bd71815-vsys-
> > mon-det"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_WDG_TEMP, "bd71815-chg-
> > wdg-temp"),
> > +   DEFINE_RES_IRQ_NAMED(BD71815_INT_CHG_WDG_TIME, "bd71815-chg-
> > 

[PATCH v4 01/23] powerpc/32s: Add missing call to kuep_lock on syscall entry

2021-01-25 Thread Christophe Leroy
Userspace Execution protection and fast syscall entry were implemented
independently from each other and were both merged in kernel 5.2,
leading to syscall entry missing userspace execution protection.

On syscall entry, execution of user space memory must be
locked in the same way as on exception entry.

Fixes: b86fb88855ea ("powerpc/32: implement fast entry for syscalls on non 
BOOKE")
Cc: sta...@vger.kernel.org
Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/entry_32.S | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index b102b40c4988..b1e36602c013 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -351,6 +351,9 @@ trace_syscall_entry_irq_off:
 
.globl  transfer_to_syscall
 transfer_to_syscall:
+#ifdef CONFIG_PPC_BOOK3S_32
+   kuep_lock r11, r12
+#endif
 #ifdef CONFIG_TRACE_IRQFLAGS
andi.   r12,r9,MSR_EE
beq-trace_syscall_entry_irq_off
-- 
2.25.0



[PATCH v4 02/23] powerpc/32: Always enable data translation on syscall entry

2021-01-25 Thread Christophe Leroy
If the code can use a stack in vm area, it can also use a
stack in linear space.

Simplify code by removing old non VMAP stack code on PPC32 in syscall.

That means the data translation is now re-enabled early in
syscall entry in all cases, not only when using VMAP stacks.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/head_32.h| 23 +--
 arch/powerpc/kernel/head_booke.h |  2 --
 2 files changed, 1 insertion(+), 24 deletions(-)

diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h
index a2f72c966baf..fdc07beab844 100644
--- a/arch/powerpc/kernel/head_32.h
+++ b/arch/powerpc/kernel/head_32.h
@@ -118,7 +118,6 @@
 .macro SYSCALL_ENTRY trapno
mfspr   r12,SPRN_SPRG_THREAD
mfspr   r9, SPRN_SRR1
-#ifdef CONFIG_VMAP_STACK
mfspr   r11, SPRN_SRR0
mtctr   r11
andi.   r11, r9, MSR_PR
@@ -126,30 +125,16 @@
lwz r1,TASK_STACK-THREAD(r12)
beq-99f
addir1, r1, THREAD_SIZE - INT_FRAME_SIZE
-   li  r10, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */
+   LOAD_REG_IMMEDIATE(r10, MSR_KERNEL & ~(MSR_IR | MSR_RI)) /* can take 
DTLB miss */
mtmsr   r10
isync
tovirt(r12, r12)
stw r11,GPR1(r1)
stw r11,0(r1)
mr  r11, r1
-#else
-   andi.   r11, r9, MSR_PR
-   lwz r11,TASK_STACK-THREAD(r12)
-   beq-99f
-   addir11, r11, THREAD_SIZE - INT_FRAME_SIZE
-   tophys(r11, r11)
-   stw r1,GPR1(r11)
-   stw r1,0(r11)
-   tovirt(r1, r11) /* set new kernel sp */
-#endif
mflrr10
stw r10, _LINK(r11)
-#ifdef CONFIG_VMAP_STACK
mfctr   r10
-#else
-   mfspr   r10,SPRN_SRR0
-#endif
stw r10,_NIP(r11)
mfcrr10
rlwinm  r10,r10,0,4,2   /* Clear SO bit in CR */
@@ -157,11 +142,7 @@
 #ifdef CONFIG_40x
rlwinm  r9,r9,0,14,12   /* clear MSR_WE (necessary?) */
 #else
-#ifdef CONFIG_VMAP_STACK
LOAD_REG_IMMEDIATE(r10, MSR_KERNEL & ~MSR_IR) /* can take exceptions */
-#else
-   LOAD_REG_IMMEDIATE(r10, MSR_KERNEL & ~(MSR_IR|MSR_DR)) /* can take 
exceptions */
-#endif
mtmsr   r10 /* (except for mach check in rtas) */
 #endif
lis r10,STACK_FRAME_REGS_MARKER@ha /* exception frame marker */
@@ -190,7 +171,6 @@
li  r12,-1  /* clear all pending debug events */
mtspr   SPRN_DBSR,r12
lis r11,global_dbcr0@ha
-   tophys(r11,r11)
addir11,r11,global_dbcr0@l
lwz r12,0(r11)
mtspr   SPRN_DBCR0,r12
@@ -200,7 +180,6 @@
 #endif
 
 3:
-   tovirt_novmstack r2, r2 /* set r2 to current */
lis r11, transfer_to_syscall@h
ori r11, r11, transfer_to_syscall@l
 #ifdef CONFIG_TRACE_IRQFLAGS
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index bf33af714d11..706cd9368992 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -144,7 +144,6 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV)
li  r12,-1  /* clear all pending debug events */
mtspr   SPRN_DBSR,r12
lis r11,global_dbcr0@ha
-   tophys(r11,r11)
addir11,r11,global_dbcr0@l
 #ifdef CONFIG_SMP
lwz r10, TASK_CPU(r2)
@@ -158,7 +157,6 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV)
stw r12,4(r11)
 
 3:
-   tovirt(r2, r2)  /* set r2 to current */
lis r11, transfer_to_syscall@h
ori r11, r11, transfer_to_syscall@l
 #ifdef CONFIG_TRACE_IRQFLAGS
-- 
2.25.0



Re: [PATCH] genirq/msi: Activate Multi-MSI early when MSI_FLAG_ACTIVATE_EARLY is set

2021-01-25 Thread Marc Zyngier

On 2021-01-25 14:39, Shameerali Kolothum Thodi wrote:

-Original Message-
From: Marc Zyngier [mailto:m...@kernel.org]
Sent: 23 January 2021 12:28
To: linux-kernel@vger.kernel.org
Cc: Thomas Gleixner ; Bjorn Helgaas
; Shameerali Kolothum Thodi
; sta...@vger.kernel.org
Subject: [PATCH] genirq/msi: Activate Multi-MSI early when
MSI_FLAG_ACTIVATE_EARLY is set

When MSI_FLAG_ACTIVATE_EARLY is set (which is the case for PCI),
we perform the activation of the interrupt (which in the case of
PCI results in the endpoint being programmed) as soon as the
interrupt is allocated.

But it appears that this is only done for the first vector,
introducing an inconsistent behaviour for PCI Multi-MSI.

Fix it by iterating over the number of vectors allocated to
each MSI descriptor. This is easily achieved by introducing
a new "for_each_msi_vector" iterator, together with a tiny
bit of refactoring.

Fixes: f3b0946d629c ("genirq/msi: Make sure PCI MSIs are activated 
early")

Reported-by: Shameer Kolothum 
Signed-off-by: Marc Zyngier 
Cc: sta...@vger.kernel.org
---
 include/linux/msi.h |  6 ++
 kernel/irq/msi.c| 44 
 2 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/include/linux/msi.h b/include/linux/msi.h
index 360a0a7e7341..aef35fd1cf11 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -178,6 +178,12 @@ struct msi_desc {
list_for_each_entry((desc), dev_to_msi_list((dev)), list)
 #define for_each_msi_entry_safe(desc, tmp, dev)\
 	list_for_each_entry_safe((desc), (tmp), dev_to_msi_list((dev)), 
list)

+#define for_each_msi_vector(desc, __irq, dev)  \
+   for_each_msi_entry((desc), (dev))   \
+   if ((desc)->irq) \
+   for (__irq = (desc)->irq;\
+__irq < ((desc)->irq + (desc)->nvec_used);\
+__irq++)

 #ifdef CONFIG_IRQ_MSI_IOMMU
 static inline const void *msi_desc_get_iommu_cookie(struct msi_desc 
*desc)

diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index 2c0c4d6d0f83..d924676c8781 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -436,22 +436,22 @@ int __msi_domain_alloc_irqs(struct irq_domain
*domain, struct device *dev,

can_reserve = msi_check_reservation_mode(domain, info, dev);

-   for_each_msi_entry(desc, dev) {
-   virq = desc->irq;
-   if (desc->nvec_used == 1)
-   dev_dbg(dev, "irq %d for MSI\n", virq);
-   else
+   /*
+* This flag is set by the PCI layer as we need to activate
+* the MSI entries before the PCI layer enables MSI in the
+* card. Otherwise the card latches a random msi message.
+*/
+   if (!(info->flags & MSI_FLAG_ACTIVATE_EARLY))
+   goto skip_activate;


This will change the dbg print behavior. From the commit f3b0946d629c,
it looks like the below dev_dbg() code was there for 
!MSI_FLAG_ACTIVATE_EARLY

case as well. Not sure how much this matters though.


I'm not sure this matters either. We may have relied on these statements
some 6/7 years ago, as the whole hierarchy stuff was brand new, but we
now have a much better debug infrastructure thanks to Thomas. I'd be
totally in favour of dropping it.

Thanks,

M.
--
Jazz is not dead. It just smells funny...


[PATCH v4 04/23] powerpc/32: Reorder instructions to avoid using CTR in syscall entry

2021-01-25 Thread Christophe Leroy
Now that we are using rfi instead of mtmsr to reactivate MMU, it is
possible to reorder instructions and avoid the need to use CTR for
stashing SRR0.

null_syscall on 8xx is reduced by 3 cycles (283 => 280 cycles).

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/head_32.h | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h
index 4029c51dce5d..24dc326e0d56 100644
--- a/arch/powerpc/kernel/head_32.h
+++ b/arch/powerpc/kernel/head_32.h
@@ -116,30 +116,28 @@
 .endm
 
 .macro SYSCALL_ENTRY trapno
-   mfspr   r12,SPRN_SPRG_THREAD
mfspr   r9, SPRN_SRR1
-   mfspr   r11, SPRN_SRR0
-   mtctr   r11
+   mfspr   r10, SPRN_SRR0
andi.   r11, r9, MSR_PR
+   beq-99f
+   LOAD_REG_IMMEDIATE(r11, MSR_KERNEL) /* can take exceptions 
*/
+   lis r12, 1f@h
+   ori r12, r12, 1f@l
+   mtspr   SPRN_SRR1, r11
+   mtspr   SPRN_SRR0, r12
+   mfspr   r12,SPRN_SPRG_THREAD
mr  r11, r1
lwz r1,TASK_STACK-THREAD(r12)
-   beq-99f
+   tovirt(r12, r12)
addir1, r1, THREAD_SIZE - INT_FRAME_SIZE
-   LOAD_REG_IMMEDIATE(r10, MSR_KERNEL) /* can take exceptions 
*/
-   mtspr   SPRN_SRR1, r10
-   lis r10, 1f@h
-   ori r10, r10, 1f@l
-   mtspr   SPRN_SRR0, r10
rfi
 1:
-   tovirt(r12, r12)
stw r11,GPR1(r1)
stw r11,0(r1)
mr  r11, r1
+   stw r10,_NIP(r11)
mflrr10
stw r10, _LINK(r11)
-   mfctr   r10
-   stw r10,_NIP(r11)
mfcrr10
rlwinm  r10,r10,0,4,2   /* Clear SO bit in CR */
stw r10,_CCR(r11)   /* save registers */
-- 
2.25.0



[PATCH v4 03/23] powerpc/32: On syscall entry, enable instruction translation at the same time as data

2021-01-25 Thread Christophe Leroy
On 40x and 8xx, kernel text is pinned.
On book3s/32, kernel text is mapped by BATs.

Enable instruction translation at the same time as data translation, it
makes things simpler.

MSR_RI can also be set at the same time because srr0/srr1 are already
saved and r1 is set properly.

On booke, translation is always on, so at the end all PPC32
have translation on early.

This reduces null_syscall benchmark by 13 cycles on 8xx
(296 ==> 283 cycles).

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/head_32.h| 26 +-
 arch/powerpc/kernel/head_booke.h |  7 ++-
 2 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h
index fdc07beab844..4029c51dce5d 100644
--- a/arch/powerpc/kernel/head_32.h
+++ b/arch/powerpc/kernel/head_32.h
@@ -125,9 +125,13 @@
lwz r1,TASK_STACK-THREAD(r12)
beq-99f
addir1, r1, THREAD_SIZE - INT_FRAME_SIZE
-   LOAD_REG_IMMEDIATE(r10, MSR_KERNEL & ~(MSR_IR | MSR_RI)) /* can take 
DTLB miss */
-   mtmsr   r10
-   isync
+   LOAD_REG_IMMEDIATE(r10, MSR_KERNEL) /* can take exceptions 
*/
+   mtspr   SPRN_SRR1, r10
+   lis r10, 1f@h
+   ori r10, r10, 1f@l
+   mtspr   SPRN_SRR0, r10
+   rfi
+1:
tovirt(r12, r12)
stw r11,GPR1(r1)
stw r11,0(r1)
@@ -141,9 +145,6 @@
stw r10,_CCR(r11)   /* save registers */
 #ifdef CONFIG_40x
rlwinm  r9,r9,0,14,12   /* clear MSR_WE (necessary?) */
-#else
-   LOAD_REG_IMMEDIATE(r10, MSR_KERNEL & ~MSR_IR) /* can take exceptions */
-   mtmsr   r10 /* (except for mach check in rtas) */
 #endif
lis r10,STACK_FRAME_REGS_MARKER@ha /* exception frame marker */
stw r2,GPR2(r11)
@@ -180,8 +181,6 @@
 #endif
 
 3:
-   lis r11, transfer_to_syscall@h
-   ori r11, r11, transfer_to_syscall@l
 #ifdef CONFIG_TRACE_IRQFLAGS
/*
 * If MSR is changing we need to keep interrupts disabled at this point
@@ -193,15 +192,8 @@
 #else
LOAD_REG_IMMEDIATE(r10, MSR_KERNEL | MSR_EE)
 #endif
-#if defined(CONFIG_PPC_8xx) && defined(CONFIG_PERF_EVENTS)
-   mtspr   SPRN_NRI, r0
-#endif
-   mtspr   SPRN_SRR1,r10
-   mtspr   SPRN_SRR0,r11
-   rfi /* jump to handler, enable MMU */
-#ifdef CONFIG_40x
-   b . /* Prevent prefetch past rfi */
-#endif
+   mtmsr   r10
+   b   transfer_to_syscall /* jump to handler */
 99:b   ret_from_kernel_syscall
 .endm
 
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index 706cd9368992..b3c502c503a0 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -157,8 +157,6 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV)
stw r12,4(r11)
 
 3:
-   lis r11, transfer_to_syscall@h
-   ori r11, r11, transfer_to_syscall@l
 #ifdef CONFIG_TRACE_IRQFLAGS
/*
 * If MSR is changing we need to keep interrupts disabled at this point
@@ -172,9 +170,8 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV)
lis r10, (MSR_KERNEL | MSR_EE)@h
ori r10, r10, (MSR_KERNEL | MSR_EE)@l
 #endif
-   mtspr   SPRN_SRR1,r10
-   mtspr   SPRN_SRR0,r11
-   rfi /* jump to handler, enable MMU */
+   mtmsr   r10
+   b   transfer_to_syscall /* jump to handler */
 99:b   ret_from_kernel_syscall
 .endm
 
-- 
2.25.0



LTP: madvise08.c:203: TFAIL: No sequence in dump after MADV_DODUMP.

2021-01-25 Thread Naresh Kamboju
LTP syscalls madvise08 test case failed on all devices from
Linux next 20210118 to till day.
strace log attached to this email and link provided below.

BAD: next-20210118
GOOD: next-20210115

This failure is easily reproducible on Linux next tag 20210118 above.

tst_test.c:1250: TINFO: Timeout per run is 0h 15m 00s
madvise08.c:73: TINFO: Temporary core pattern is
'/scratch/ltp-2nftQzNI1K/HclFMH/dump-%p'
madvise08.c:112: TINFO: Dump file should be dump-10109
madvise08.c:196: TPASS: madvise(..., MADV_DONTDUMP)
madvise08.c:112: TINFO: Dump file should be dump-10110
madvise08.c:203: TFAIL: No sequence in dump after MADV_DODUMP.

strace log,
https://lkft.validation.linaro.org/scheduler/job/2184866#L1257

Full test log link,
https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20210118/testrun/3771572/suite/ltp-syscalls-tests/test/madvise08/log

Test case link,
https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/madvise/madvise08.c#L203

metadata:
  git branch: master
  git repo: https://gitlab.com/Linaro/lkft/mirrors/next/linux-next
  git describe: next-20210118
  kernel-config: https://builds.tuxbuild.com/1nERt1Y6o3JSvLbiPXYTb9PMo1O/config

-- 
Linaro LKFT
https://lkft.linaro.org
+ cd /opt/ltp/testcases/bin/
+ strace -f ./madvise08
execve(\"./madvise08\", [\"./madvise08\"], 0x7ffd189342b8 /* 22 vars */) = 0
brk(NULL)   = 0x2542000
access(\"/etc/ld.so.preload\", R_OK)  = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, \"/etc/ld.so.cache\", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=20188, ...}) = 0
mmap(NULL, 20188, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fc414fd7000
close(3)= 0
openat(AT_FDCWD, \"/lib/libc.so.6\", O_RDONLY|O_CLOEXEC) = 3
read(3, \"\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\33\2\0\0\0\0\0\"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1771456, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc414fd5000
mmap(NULL, 3877600, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fc414a05000
mprotect(0x7fc414baf000, 2093056, PROT_NONE) = 0
mmap(0x7fc414dae000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1a9000) = 0x7fc414dae000
mmap(0x7fc414db4000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fc414db4000
close(3)= 0
arch_prctl(ARCH_SET_FS, 0x7fc414fd65c0) = 0
mprotect(0x7fc414dae000, 16384, PROT_READ) = 0
mprotect(0x61e000, 4096, PROT_READ) = 0
mprotect(0x7fc414fdc000, 4096, PROT_READ) = 0
munmap(0x7fc414fd7000, 20188)   = 0
getpid()= 484
geteuid()   = 0
uname({sysname=\"Linux\", nodename=\"intel-corei7-64\", ...}) = 0
access(\"/dev/shm\", F_OK)= 0
getpid()= 484
openat(AT_FDCWD, \"/dev/shm/ltp_madvise08_484\", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
chmod(\"/dev/shm/ltp_madvise08_484\", 0666) = 0
ftruncate(3, 4096)  = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0x7fc414fdb000
unlink(\"/dev/shm/ltp_madvise08_484\")= 0
close(3)= 0
getpid()= 484
mkdir(\"/tmp/YtwWXr\", 0700)  = 0
brk(NULL)   = 0x2542000
brk(0x2563000)  = 0x2563000
getgid()= 0
chown(\"/tmp/YtwWXr\", -1, 0) = 0
chmod(\"/tmp/YtwWXr\", 0777)  = 0
getcwd(\"/opt/ltp/testcases/bin\", 4096)  = 23
chdir(\"/tmp/YtwWXr\")= 0
access(\"/proc/sys/kernel/core_pattern\", F_OK) = 0
openat(AT_FDCWD, \"/proc/sys/kernel/core_pattern\", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
read(3, \"|/bin/false\n\", 1024)  = 12
close(3)= 0
rt_sigaction(SIGALRM, {sa_handler=0x406360, sa_mask=[ALRM], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fc414a395b0}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGUSR1, {sa_handler=0x406200, sa_mask=[USR1], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fc414a395b0}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
ioctl(2, TCGETS, {B115200 opost isig icanon echo ...}) = 0
write(2, \"tst_test.c:1250: \33[1;34mTINFO: \33\"..., 65tst_test.c:1250: [1;34mTINFO: [0mTimeout per run is 0h 05m 00s
) = 65
getpid()= 484
alarm(300)  = 0
rt_sigaction(SIGINT, {sa_handler=0x406310, sa_mask=[INT], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fc414a395b0}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fc414fd6890) = 485
strace: Process 485 attached
[pid   484] wait4(485,  
[pid   485] rt_sigaction(SIGALRM, {sa_handler=SIG_DFL, sa_mask=[ALRM], 

Re: [PATCH v2] tracing: precise log info for kretprobe addr err

2021-01-25 Thread Steven Rostedt
On Mon, 25 Jan 2021 03:14:03 +
Jianlin Lv  wrote:

> Hi Steven,
> Could you give me more detailed suggestions about the UPROBES section? I lack 
> the knowledge of this part.
> Can't fully understand your previous comments;

Sorry for the confusion. I was talking about the MAINTAINERS file. That
there's no "UPROBES" section in it.

-- Steve


Re: [PATCH 4/4] vfio-pci/zdev: Introduce the zPCI I/O vfio region

2021-01-25 Thread Matthew Rosato

On 1/22/21 6:48 PM, Alex Williamson wrote:

On Tue, 19 Jan 2021 15:02:30 -0500
Matthew Rosato  wrote:


Some s390 PCI devices (e.g. ISM) perform I/O operations that have very
specific requirements in terms of alignment as well as the patterns in
which the data is read/written. Allowing these to proceed through the
typical vfio_pci_bar_rw path will cause them to be broken in up in such a
way that these requirements can't be guaranteed. In addition, ISM devices
do not support the MIO codepaths that might be triggered on vfio I/O coming
from userspace; we must be able to ensure that these devices use the
non-MIO instructions.  To facilitate this, provide a new vfio region by
which non-MIO instructions can be passed directly to the host kernel s390
PCI layer, to be reliably issued as non-MIO instructions.

This patch introduces the new vfio VFIO_REGION_SUBTYPE_IBM_ZPCI_IO region
and implements the ability to pass PCISTB and PCILG instructions over it,
as these are what is required for ISM devices.


There have been various discussions about splitting vfio-pci to allow
more device specific drivers rather adding duct tape and bailing wire
for various device specific features to extend vfio-pci.  The latest
iteration is here[1].  Is it possible that such a solution could simply
provide the standard BAR region indexes, but with an implementation that
works on s390, rather than creating new device specific regions to
perform the same task?  Thanks,

Alex

[1]https://lore.kernel.org/lkml/20210117181534.65724-1-mgurto...@nvidia.com/



Thanks for the pointer, I'll have to keep an eye on this.  An approach 
like this could solve some issues, but I think a main issue that still 
remains with relying on the standard BAR region indexes (whether using 
the current vfio-pci driver or a device-specific driver) is that QEMU 
writes to said BAR memory region are happening in, at most, 8B chunks 
(which then, in the current general-purpose vfio-pci code get further 
split up into 4B iowrite operations).  The alternate approach I'm 
proposing here is allowing for the whole payload (4K) in a single 
operation, which is significantly faster.  So, I suspect even with a 
device specific driver we'd want this sort of a region anyhow..


YOU HAVE WON

2021-01-25 Thread lottonlxxx
LOTTO.NL,
2391  Beds 152 Koningin Julianaplein 21,
Den Haag-Netherlands.
(Lotto affiliate with Subscriber Agents).
From: Susan Console
(Lottery Coordinator)
Website: www.lotto.nl

Sir/Madam,

CONGRATULATIONS!!!

We are pleased to inform you of the result of the Lotto NL Winners 
International programs held on the 14th of January 2021.  Your e-mail address 
attached to ticket #: 00903228100 with prize # 778009/UK drew €1,000,000.00 
which was first in the 2nd class of the draws. you are to receive €1,000,000.00 
(One Million Euros). Because of mix up in cash
pay-outs, we ask that you keep your winning information confidential until your 
money (€1,000,000.00) has been fully remitted to you by our accredited 
pay-point bank. 

This measure must be adhere to  avoid loss of your cash prize-winners of our 
cash prizes are advised to adhere to these instructions to forestall the abuse 
of this program by other participants.  

It's important to note that this draws were conducted formally, and winners are 
selected through an internet ballot system from 60,000 individual and companies 
e-mail addresses - the draws are conducted around the world through our 
internet based ballot system. The promotion is sponsored and promoted Lotto NL. 

We congratulate you once again. We hope you will use part of it in our next 
draws; the jackpot winning is €85million.  Remember, all winning must be 
claimed not later than 20 days. After this date all unclaimed cash prize will 
be forfeited and included in the next sweepstake.  Please, in order to avoid 
unnecessary delays and complications remember to quote personal and winning 
numbers in all correspondence with us.

Congratulations once again from all members of Lotto NL. Thank you for being 
part of our promotional program.

To file for the release of your winnings you are advice to contact our Foreign 
Transfer Manager:

MR. WILSON WARREN JOHNSON

Tel: +31-620-561-787

Fax: +31-84-438-5342

Email: johnsonwilson...@gmail.com





Re: [PATCH] ath9k: fix build error with LEDS_CLASS=m

2021-01-25 Thread Arnd Bergmann
On Mon, Jan 25, 2021 at 2:27 PM Krzysztof Kozlowski  wrote:
> On Mon, 25 Jan 2021 at 14:09, Arnd Bergmann  wrote:
> > On Mon, Jan 25, 2021 at 12:40 PM Krzysztof Kozlowski  
> > wrote:
> > > On Mon, 25 Jan 2021 at 12:36, Arnd Bergmann  wrote:
> > > But we do not want to have this dependency (selecting MAC80211_LEDS).
> > > I fixed this problem here:
> > > https://lore.kernel.org/lkml/20201227143034.1134829-1-k...@kernel.org/
> > > Maybe let's take this approach?
> >
> > Generally speaking, I don't like to have a device driver specific Kconfig
> > setting 'select' a subsystem', for two reasons:
> >
> > - you suddenly get asked for tons of new LED specific options when
> >   enabling seemingly benign options
> >
> > - Mixing 'depends on' and 'select' leads to bugs with circular
> >   dependencies that usually require turning some other 'select'
> >   into 'depends on'.
> >
> > The problem with LEDS_CLASS in particular is that there is a mix of drivers
> > using one vs the other roughly 50:50.
>
> Yes, you are right, I also don't like it. However it was like this
> before my commit so I am not introducing a new issue. The point is
> that in your choice the MAC80211_LEDS will be selected if LEDS_CLASS
> is present, which is exactly what I was trying to fix/remove. My WiFi
> dongle does not have a LED and it causes a periodic (every second)
> event. However I still have LEDS_CLASS for other LEDS in the system.

What is the effect of this lost event every second? If it causes some
runtime warning or other problem, then neither of our fixes would
solve it completely, because someone with a distro kernel would
see the same issue when they have the symbol enabled but no
physical LED in the device.

  Arnd


Re: [RFC PATCH v1] sched/fair: limit load balance redo times at the same sched_domain level

2021-01-25 Thread Mel Gorman
On Mon, Jan 25, 2021 at 09:53:28PM +0800, Li, Aubrey wrote:
> On 2021/1/25 17:06, Mel Gorman wrote:
> > On Mon, Jan 25, 2021 at 02:02:58PM +0800, Aubrey Li wrote:
> >> A long-tail load balance cost is observed on the newly idle path,
> >> this is caused by a race window between the first nr_running check
> >> of the busiest runqueue and its nr_running recheck in detach_tasks.
> >>
> >> Before the busiest runqueue is locked, the tasks on the busiest
> >> runqueue could be pulled by other CPUs and nr_running of the busiest
> >> runqueu becomes 1, this causes detach_tasks breaks with LBF_ALL_PINNED
> >> flag set, and triggers load_balance redo at the same sched_domain level.
> >>
> >> In order to find the new busiest sched_group and CPU, load balance will
> >> recompute and update the various load statistics, which eventually leads
> >> to the long-tail load balance cost.
> >>
> >> This patch introduces a variable(sched_nr_lb_redo) to limit load balance
> >> redo times, combined with sysctl_sched_nr_migrate, the max load balance
> >> cost is reduced from 100+ us to 70+ us, measured on a 4s x86 system with
> >> 192 logical CPUs.
> >>
> >> Cc: Andi Kleen 
> >> Cc: Tim Chen 
> >> Cc: Srinivas Pandruvada 
> >> Cc: Rafael J. Wysocki 
> >> Signed-off-by: Aubrey Li 
> > 
> > If redo_max is a constant, why is it not a #define instead of increasing
> > the size of lb_env?
> > 
> 
> I followed the existing variable sched_nr_migrate_break, I think this might
> be a tunable as well.
> 

I don't think it is, the tunable is sched_nr_migrate and it's not clear
to me at all why sched_nr_migrate_break is not also a #define. It just
happens that sched_nr_migrate == sched_nr_migrate_break by default.

-- 
Mel Gorman
SUSE Labs


Re: [PATCH] ARM: dts: stm32: Add STM32MP1 I2C6 SDA/SCL pinmux

2021-01-25 Thread Alexandre TORGUE

Hi,

On 12/23/20 12:07 PM, Jagan Teki wrote:

Add SDA/SCL pinmux lines for I2C6 on STM32MP1.

This support adds both in default and sleep states.

Signed-off-by: Jagan Teki 
---
  arch/arm/boot/dts/stm32mp15-pinctrl.dtsi | 17 +
  1 file changed, 17 insertions(+)

diff --git a/arch/arm/boot/dts/stm32mp15-pinctrl.dtsi 
b/arch/arm/boot/dts/stm32mp15-pinctrl.dtsi
index 20a59e8f7a33..2036c1d0d798 100644
--- a/arch/arm/boot/dts/stm32mp15-pinctrl.dtsi
+++ b/arch/arm/boot/dts/stm32mp15-pinctrl.dtsi
@@ -2018,6 +2018,23 @@ pins {
};
};
  
+	i2c6_pins_a: i2c6-0 {

+   pins {
+   pinmux = , /* I2C6_SCL */
+; /* I2C6_SDA */
+   bias-disable;
+   drive-open-drain;
+   slew-rate = <0>;
+   };
+   };
+
+   i2c6_sleep_pins_a: i2c6-sleep-0 {
+   pins {
+   pinmux = , /* I2C6_SCL */
+; /* I2C6_SDA */
+   };
+   };
+
spi1_pins_a: spi1-0 {
pins1 {
pinmux = , /* SPI1_SCK */



Applied on stm32-next.

Thanks.
Alex


Re: [PATCH] regulator: pf8x00: Add suspend support

2021-01-25 Thread Mark Brown
On Sun, 17 Jan 2021 21:49:17 +0100, Christoph Fritz wrote:
> This patch adds suspend/resume support so that it is possible to
> configure the LDOs and BUCKs as on or off during suspend phase as
> well as to configure suspend specific voltages.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 
for-next

Thanks!

[1/1] regulator: pf8x00: Add suspend support
  commit: 7fefe72b0f8c0d7e63af9810c4dcc88757eddcd5

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


Re: [PATCH wireless v2] scsi: megaraid: Remove unnecessary memset

2021-01-25 Thread Kalle Valo
Zheng Yongjun  wrote:

> memcpy operation is next to memset code, and the size to copy
> is equals to the size to memset, so the memset operation is
> unnecessary, remove it.
> 
> Signed-off-by: Zheng Yongjun 

Wrong title.

Patch set to Changes Requested.

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20210115014559.7803-1-zhengyongj...@huawei.com/

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



Re: [PATCH] regulator: core: Avoid debugfs: Directory ... already present! error

2021-01-25 Thread Mark Brown
On Fri, 22 Jan 2021 19:32:50 +0100, Hans de Goede wrote:
> Sometimes regulator_get() gets called twice for the same supply on the
> same device. This may happen e.g. when a framework / library is used
> which uses the regulator; and the driver itself also needs to enable
> the regulator in some cases where the framework will not enable it.
> 
> Commit ff268b56ce8c ("regulator: core: Don't spew backtraces on
> duplicate sysfs") already takes care of the backtrace which would
> trigger when creating a duplicate consumer symlink under
> /sys/class/regulator/regulator.%d in this scenario.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 
for-next

Thanks!

[1/1] regulator: core: Avoid debugfs: Directory ... already present! error
  commit: dbe954d8f1635f949a1d9a5d6e6fb749ae022b47

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


Re: [PATCH v6 3/7] mfd: Add MFD driver for ATC260x PMICs

2021-01-25 Thread Lee Jones
On Wed, 20 Jan 2021, Cristian Ciocaltea wrote:

> Add initial support for the Actions Semi ATC260x PMICs which integrates
> Audio Codec, Power management, Clock generation and GPIO controller
> blocks.
> 
> For the moment this driver only supports Regulator, Poweroff and Onkey
> functionalities for the ATC2603C and ATC2609A chip variants.
> 
> Since the PMICs can be accessed using both I2C and SPI buses, the
> following driver structure has been adopted:
> 
>-> atc260x-core.c (Implements core functionalities)
>   /
> ATC260x > atc260x-i2c.c (Implements I2C interface)
>   \
>-> atc260x-spi.c (Implements SPI interface - TODO)
> 
> Co-developed-by: Manivannan Sadhasivam 
> Signed-off-by: Manivannan Sadhasivam 
> Signed-off-by: Cristian Ciocaltea 
> ---
> Changes in v6 - per Lee's feedback:
> - Added ATC260X_CHIP_REV_MAX magic number
> - Fixed code formattting arround atc260x_i2c_driver initialization
> - Replaced dev_init() callback in struct atc260x with a pointer to a new 
> struct
> atc260x_init_regs to hold hardware specific registry information
> - Added a generic atc260x_dev_init() function and instantiated 
> atc2603c_init_regs
> and atc2609a_init_regs
> 
> Changes in v5:
>  - None
> 
> Changes in v4 - according to Lee's review:
>  - Replaced 'regmap_add_irq_chip()' with 'devm' counterpart and dropped
>'atc260x_device_remove()' and 'atc260x_i2c_remove()' functions
>  - Moved kerneldoc sections from prototypes to real functions
>  - Placed single line entries on one line for mfd_cells[]
>  - Several other minor changes
> 
> Changes in v3:
>  - Fixed the issues reported by Lee's kernel test robot:
>WARNING: modpost: missing MODULE_LICENSE() in drivers/mfd/atc260x-core.o
>>> FATAL: modpost: drivers/mfd/atc260x-i2c: sizeof(struct 
> i2c_device_id)=24 is
>   not a modulo of the size of section 
> __mod_i2c___device_table=588.
>>> Fix definition of struct i2c_device_id in mod_devicetable.h
>  - Dropped the usage of '.of_compatible' fields in 
> {atc2603c,atc2609a}_mfd_cells[]
>  - Added 'Co-developed-by' tag in commit message and dropped [cristian: ...] 
> line
> 
>  drivers/mfd/Kconfig  |  18 ++
>  drivers/mfd/Makefile |   3 +
>  drivers/mfd/atc260x-core.c   | 310 +++
>  drivers/mfd/atc260x-i2c.c|  64 ++
>  include/linux/mfd/atc260x/atc2603c.h | 281 
>  include/linux/mfd/atc260x/atc2609a.h | 308 ++
>  include/linux/mfd/atc260x/core.h |  58 +
>  7 files changed, 1042 insertions(+)
>  create mode 100644 drivers/mfd/atc260x-core.c
>  create mode 100644 drivers/mfd/atc260x-i2c.c
>  create mode 100644 include/linux/mfd/atc260x/atc2603c.h
>  create mode 100644 include/linux/mfd/atc260x/atc2609a.h
>  create mode 100644 include/linux/mfd/atc260x/core.h
> 
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index bdfce7b15621..a27ff2e83e7a 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -2064,6 +2064,24 @@ config MFD_WCD934X
> This driver provides common support WCD934x audio codec and its
> associated Pin Controller, Soundwire Controller and Audio codec.
>  
> +config MFD_ATC260X
> + tristate
> + select MFD_CORE
> + select REGMAP
> + select REGMAP_IRQ
> +
> +config MFD_ATC260X_I2C
> + tristate "Actions Semi ATC260x PMICs with I2C"
> + select MFD_ATC260X
> + select REGMAP_I2C
> + depends on I2C
> + help
> +   Support for the Actions Semi ATC260x PMICs controlled via I2C.
> +
> +   This driver provides common support for accessing the ATC2603C
> +   and ATC2609A chip variants, additional drivers must be enabled
> +   in order to use the functionality of the device.
> +
>  config MFD_KHADAS_MCU
>   tristate "Support for Khadas System control Microcontroller"
>   depends on I2C
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 14fdb188af02..1ea88d2c83b4 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -268,3 +268,6 @@ obj-$(CONFIG_MFD_KHADAS_MCU)  += khadas-mcu.o
>  obj-$(CONFIG_SGI_MFD_IOC3)   += ioc3.o
>  obj-$(CONFIG_MFD_SIMPLE_MFD_I2C) += simple-mfd-i2c.o
>  obj-$(CONFIG_MFD_INTEL_M10_BMC)   += intel-m10-bmc.o
> +
> +obj-$(CONFIG_MFD_ATC260X)+= atc260x-core.o
> +obj-$(CONFIG_MFD_ATC260X_I2C)+= atc260x-i2c.o
> diff --git a/drivers/mfd/atc260x-core.c b/drivers/mfd/atc260x-core.c
> new file mode 100644
> index ..7148ff5b05b1
> --- /dev/null
> +++ b/drivers/mfd/atc260x-core.c
> @@ -0,0 +1,310 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Core support for ATC260x PMICs
> + *
> + * Copyright (C) 2019 Manivannan Sadhasivam 
> 
> + * Copyright (C) 2020 Cristian Ciocaltea 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define ATC260X_CHIP_REV_MAX 31
> +
> +struct 

Re: Fail to boot qemu xlnx-zcu102 due to lot of drivers not probing

2021-01-25 Thread Corentin Labbe
Le Fri, Jan 22, 2021 at 11:51:53AM +0100, Edgar E. Iglesias a écrit :
> On Fri, Jan 22, 2021 at 10:52:18AM +0100, Michal Simek wrote:
> > Hi,
> > 
> > On 1/22/21 10:24 AM, Corentin Labbe wrote:
> > > Hello
> > > 
> > > With at least qemu 5.1.0 (and later), the xlnx-zcu102 machine boot lead 
> > > to a panic due to missing console.
> > > qemu-system-aarch64 -kernel Image -nographic -machine xlnx-zcu102 -device 
> > > ide-hd,drive=lavatest -serial mon:stdio -serial null -append 
> > > 'earlycon=cdns,mmio,0xFF00,115200n8 console=ttyPS0 root=/dev/ram0 
> > > ip=dhcp' -dtb zynqmp-zcu102-rev1.0.dtb -m 2048 -nic 
> > > user,model=cadence_gem,mac=52:54:00:12:34:58 -drive 
> > > format=qcow2,file=disk.img,if=none,id=lavatest -initrd rootfs.cpio.gz
> > > [0.00] Booting Linux on physical CPU 0x00 [0x410fd034]
> > > [0.00] Linux version 5.5.0-rc1-4-g9c8a47b484ed 
> > > (clabbe@arnold) (gcc version 7.5.0 (Linaro GCC 7.5-2019.12)) #17 SMP 
> > > PREEMPT Fri Jan 22 09:19:31 UTC 2021
> > > [0.00] Machine model: ZynqMP ZCU102 Rev1.0
> > > [0.00] earlycon: cdns0 at MMIO 0xff00 (options 
> > > '115200n8')
> > > [0.00] printk: bootconsole [cdns0] enabled
> > > [0.00] efi: Getting EFI parameters from FDT:
> > > [0.00] efi: UEFI not found.
> > > [0.00] cma: Reserved 32 MiB at 0x7e00
> > > [0.00] NUMA: No NUMA configuration found
> > > [0.00] NUMA: Faking a node at [mem 
> > > 0x-0x7fff]
> > > [0.00] NUMA: NODE_DATA [mem 0x7dbe0100-0x7dbe1fff]
> > > [0.00] Zone ranges:
> > > [0.00]   DMA  [mem 0x-0x3fff]
> > > [0.00]   DMA32[mem 0x4000-0x7fff]
> > > [0.00]   Normal   empty
> > > [0.00] Movable zone start for each node
> > > [0.00] Early memory node ranges
> > > [0.00]   node   0: [mem 0x-0x7fff]
> > > [0.00] Initmem setup node 0 [mem 
> > > 0x-0x7fff]
> > > [0.00] psci: probing for conduit method from DT.
> > > [0.00] psci: PSCIv0.2 detected in firmware.
> > > [0.00] psci: Using standard PSCI v0.2 function IDs
> > > [0.00] psci: Trusted OS migration not required
> > > [0.00] percpu: Embedded 22 pages/cpu s53016 r8192 d28904 u90112
> > > [0.00] Detected VIPT I-cache on CPU0
> > > [0.00] CPU features: detected: ARM erratum 845719
> > > [0.00] CPU features: detected: ARM erratum 843419
> > > [0.00] Built 1 zonelists, mobility grouping on.  Total pages: 
> > > 516096
> > > [0.00] Policy zone: DMA32
> > > [0.00] Kernel command line: 
> > > earlycon=cdns,mmio,0xFF00,115200n8 console=ttyPS0 root=/dev/ram0 
> > > ip=dhcp
> > > [0.00] Dentry cache hash table entries: 262144 (order: 9, 2097152 
> > > bytes, linear)
> > > [0.00] Inode-cache hash table entries: 131072 (order: 8, 1048576 
> > > bytes, linear)
> > > [0.00] mem auto-init: stack:off, heap alloc:off, heap free:off
> > > [0.00] software IO TLB: mapped [mem 0x3bfff000-0x3000] (64MB)
> > > [0.00] Memory: 1907172K/2097152K available (12092K kernel code, 
> > > 1896K rwdata, 6640K rodata, 5120K init, 456K bss, 157212K reserved, 
> > > 32768K cma-reserved)
> > > [0.00] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
> > > [0.00] rcu: Preemptible hierarchical RCU implementation.
> > > [0.00] rcu:   RCU restricting CPUs from NR_CPUS=256 to 
> > > nr_cpu_ids=4.
> > > [0.00]Tasks RCU enabled.
> > > [0.00] rcu: RCU calculated value of scheduler-enlistment delay is 
> > > 25 jiffies.
> > > [0.00] rcu: Adjusting geometry for rcu_fanout_leaf=16, 
> > > nr_cpu_ids=4
> > > [0.00] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
> > > [0.00] random: get_random_bytes called from 
> > > start_kernel+0x2b8/0x454 with crng_init=0
> > > [0.00] arch_timer: cp15 timer(s) running at 62.50MHz (virt).
> > > [0.00] clocksource: arch_sys_counter: mask: 0xff 
> > > max_cycles: 0x1cd42e208c, max_idle_ns: 881590405314 ns
> > > [0.000118] sched_clock: 56 bits at 62MHz, resolution 16ns, wraps 
> > > every 4398046511096ns
> > > [0.006458] Console: colour dummy device 80x25
> > > [0.008026] Calibrating delay loop (skipped), value calculated using 
> > > timer frequency.. 125.00 BogoMIPS (lpj=25)
> > > [0.008182] pid_max: default: 32768 minimum: 301
> > > [0.009157] LSM: Security Framework initializing
> > > [0.010014] Mount-cache hash table entries: 4096 (order: 3, 32768 
> > > bytes, linear)
> > > [0.010106] Mountpoint-cache hash table entries: 4096 (order: 3, 32768 
> > > bytes, linear)
> > > [0.060263] ASID allocator initialised with 32768 entries
> > > [0.067849] rcu: Hierarchical SRCU 

[PATCH v2 0/4] dmaengine: rcar-dmac: Add support for R-Car V3U

2021-01-25 Thread Geert Uytterhoeven
Hi Vinod,

This patch series adds support for the Direct Memory Access Controller
variant in the Renesas R-Car V3U (R8A779A0) SoC, to both DT bindings and
driver.

Changes compared to v1:
  - Add Reviewed-by,
  - Put the full loop control of for_each_rcar_dmac_chan() on a single
line, to improve readability,
  - Use two separate named regions instead of array,
  - Drop rcar_dmac_of_data.chan_reg_block, check for
!rcar_dmac_of_data.chan_offset_base instead,
  - Precalculate chan_base in rcar_dmac_probe().

This has been tested on the Renesas Falcon board, using external SPI
loopback (spi-loopback-test) on MSIOF1 and MSIOF2.

Thanks!

Geert Uytterhoeven (4):
  dt-bindings: renesas,rcar-dmac: Add r8a779a0 support
  dmaengine: rcar-dmac: Add for_each_rcar_dmac_chan() helper
  dmaengine: rcar-dmac: Add helpers for clearing DMA channel status
  dmaengine: rcar-dmac: Add support for R-Car V3U

 .../bindings/dma/renesas,rcar-dmac.yaml   |  76 -
 drivers/dma/sh/rcar-dmac.c| 105 +-
 2 files changed, 123 insertions(+), 58 deletions(-)

-- 
2.25.1

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[PATCH v2 2/4] dmaengine: rcar-dmac: Add for_each_rcar_dmac_chan() helper

2021-01-25 Thread Geert Uytterhoeven
Add and helper macro for iterating over all DMAC channels, taking into
account the channel mask.  Use it where appropriate, to simplify code.

Restore "reverse Christmas tree" order of local variables while adding a
new variable.

Signed-off-by: Geert Uytterhoeven 
---
v2:
  - Put the full loop control of for_each_rcar_dmac_chan() on a single
line, to improve readability.
---
 drivers/dma/sh/rcar-dmac.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index a57705356e8bb796..537550b4121bbc22 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -209,6 +209,10 @@ struct rcar_dmac {
 
 #define to_rcar_dmac(d)container_of(d, struct rcar_dmac, 
engine)
 
+#define for_each_rcar_dmac_chan(i, chan, dmac) 
\
+   for (i = 0, chan = &(dmac)->channels[0]; i < (dmac)->n_channels; i++, 
chan++)   \
+   if (!((dmac)->channels_mask & BIT(i))) continue; else
+
 /*
  * struct rcar_dmac_of_data - This driver's OF data
  * @chan_offset_base: DMAC channels base offset
@@ -817,15 +821,11 @@ static void rcar_dmac_chan_reinit(struct rcar_dmac_chan 
*chan)
 
 static void rcar_dmac_stop_all_chan(struct rcar_dmac *dmac)
 {
+   struct rcar_dmac_chan *chan;
unsigned int i;
 
/* Stop all channels. */
-   for (i = 0; i < dmac->n_channels; ++i) {
-   struct rcar_dmac_chan *chan = >channels[i];
-
-   if (!(dmac->channels_mask & BIT(i)))
-   continue;
-
+   for_each_rcar_dmac_chan(i, chan, dmac) {
/* Stop and reinitialize the channel. */
spin_lock_irq(>lock);
rcar_dmac_chan_halt(chan);
@@ -1828,9 +1828,10 @@ static int rcar_dmac_probe(struct platform_device *pdev)
DMA_SLAVE_BUSWIDTH_2_BYTES | DMA_SLAVE_BUSWIDTH_4_BYTES |
DMA_SLAVE_BUSWIDTH_8_BYTES | DMA_SLAVE_BUSWIDTH_16_BYTES |
DMA_SLAVE_BUSWIDTH_32_BYTES | DMA_SLAVE_BUSWIDTH_64_BYTES;
+   const struct rcar_dmac_of_data *data;
+   struct rcar_dmac_chan *chan;
struct dma_device *engine;
struct rcar_dmac *dmac;
-   const struct rcar_dmac_of_data *data;
unsigned int i;
int ret;
 
@@ -1916,11 +1917,8 @@ static int rcar_dmac_probe(struct platform_device *pdev)
 
INIT_LIST_HEAD(>channels);
 
-   for (i = 0; i < dmac->n_channels; ++i) {
-   if (!(dmac->channels_mask & BIT(i)))
-   continue;
-
-   ret = rcar_dmac_chan_probe(dmac, >channels[i], data, i);
+   for_each_rcar_dmac_chan(i, chan, dmac) {
+   ret = rcar_dmac_chan_probe(dmac, chan, data, i);
if (ret < 0)
goto error;
}
-- 
2.25.1



[PATCH] kdb: Refactor env variables get/set code

2021-01-25 Thread Sumit Garg
Move kdb environment related get/set APIs to a separate file in order
to provide an abstraction for environment variables access and hence
enhances code readability.

Signed-off-by: Sumit Garg 
---
 kernel/debug/kdb/Makefile  |   2 +-
 kernel/debug/kdb/kdb_env.c | 229 +
 kernel/debug/kdb/kdb_main.c| 201 +---
 kernel/debug/kdb/kdb_private.h |   3 +
 4 files changed, 235 insertions(+), 200 deletions(-)
 create mode 100644 kernel/debug/kdb/kdb_env.c

diff --git a/kernel/debug/kdb/Makefile b/kernel/debug/kdb/Makefile
index efac857..b76aebe 100644
--- a/kernel/debug/kdb/Makefile
+++ b/kernel/debug/kdb/Makefile
@@ -6,7 +6,7 @@
 # Copyright (c) 2009 Wind River Systems, Inc. All Rights Reserved.
 #
 
-obj-y := kdb_io.o kdb_main.o kdb_support.o kdb_bt.o gen-kdb_cmds.o kdb_bp.o 
kdb_debugger.o
+obj-y := kdb_io.o kdb_main.o kdb_support.o kdb_bt.o gen-kdb_cmds.o kdb_bp.o 
kdb_debugger.o kdb_env.o
 obj-$(CONFIG_KDB_KEYBOARD)+= kdb_keyboard.o
 
 clean-files := gen-kdb_cmds.c
diff --git a/kernel/debug/kdb/kdb_env.c b/kernel/debug/kdb/kdb_env.c
new file mode 100644
index 000..33ab5e6
--- /dev/null
+++ b/kernel/debug/kdb/kdb_env.c
@@ -0,0 +1,229 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Kernel Debugger Architecture Independent Environment Functions
+ *
+ * Copyright (c) 1999-2004 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2009 Wind River Systems, Inc.  All Rights Reserved.
+ * 03/02/13added new 2.5 kallsyms 
+ */
+
+#include 
+#include 
+#include "kdb_private.h"
+
+/*
+ * Initial environment.   This is all kept static and local to
+ * this file.   We don't want to rely on the memory allocation
+ * mechanisms in the kernel, so we use a very limited allocate-only
+ * heap for new and altered environment variables.  The entire
+ * environment is limited to a fixed number of entries (add more
+ * to __env[] if required) and a fixed amount of heap (add more to
+ * KDB_ENVBUFSIZE if required).
+ */
+static char *__env[] = {
+#if defined(CONFIG_SMP)
+   "PROMPT=[%d]kdb> ",
+#else
+   "PROMPT=kdb> ",
+#endif
+   "MOREPROMPT=more> ",
+   "RADIX=16",
+   "MDCOUNT=8",/* lines of md output */
+   KDB_PLATFORM_ENV,
+   "DTABCOUNT=30",
+   "NOSECT=1",
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+   (char *)0,
+};
+
+static const int __nenv = ARRAY_SIZE(__env);
+
+/*
+ * kdbgetenv - This function will return the character string value of
+ * an environment variable.
+ * Parameters:
+ * match   A character string representing an environment variable.
+ * Returns:
+ * NULLNo environment variable matches 'match'
+ * char*   Pointer to string value of environment variable.
+ */
+char *kdbgetenv(const char *match)
+{
+   char **ep = __env;
+   int matchlen = strlen(match);
+   int i;
+
+   for (i = 0; i < __nenv; i++) {
+   char *e = *ep++;
+
+   if (!e)
+   continue;
+
+   if ((strncmp(match, e, matchlen) == 0)
+&& ((e[matchlen] == '\0')
+  || (e[matchlen] == '='))) {
+   char *cp = strchr(e, '=');
+
+   return cp ? ++cp : "";
+   }
+   }
+   return NULL;
+}
+
+/*
+ * kdballocenv - This function is used to allocate bytes for
+ * environment entries.
+ * Parameters:
+ * match   A character string representing a numeric value
+ * Outputs:
+ * *value  the unsigned long representation of the env variable 'match'
+ * Returns:
+ * Zero on success, a kdb diagnostic on failure.
+ * Remarks:
+ * We use a static environment buffer (envbuffer) to hold the values
+ * of dynamically generated environment variables (see kdb_set).  Buffer
+ * space once allocated is never free'd, so over time, the amount of space
+ * (currently 512 bytes) will be exhausted if env variables are changed
+ * frequently.
+ */
+static char *kdballocenv(size_t bytes)
+{
+#defineKDB_ENVBUFSIZE  512
+   static char envbuffer[KDB_ENVBUFSIZE];
+   static int envbufsize;
+   char *ep = NULL;
+
+   if ((KDB_ENVBUFSIZE - envbufsize) >= bytes) {
+   ep = [envbufsize];
+   envbufsize += bytes;
+   }
+   return ep;
+}
+
+/*
+ * kdbgetulenv - This function will return the value of an unsigned
+ * long-valued environment variable.
+ * Parameters:
+ * match   A character string representing a numeric value
+ * Outputs:
+ * *value  the unsigned long 

Re: [PATCH v5 18/21] arm64: Move "nokaslr" over to the early cpufeature infrastructure

2021-01-25 Thread Marc Zyngier

On 2021-01-25 14:19, Ard Biesheuvel wrote:

On Mon, 25 Jan 2021 at 14:54, Marc Zyngier  wrote:


On 2021-01-25 12:54, Ard Biesheuvel wrote:


[...]


> This struct now takes up
> - ~100 bytes for the characters themselves (which btw are not emitted
> into __initdata or __initconst)
> - 6x8 bytes for the char pointers
> - 6x24 bytes for the RELA relocations that annotate these pointers as
> quantities that need to be relocated at boot (on a kernel built with
> KASLR)
>
> I know it's only a drop in the ocean, but in this case, where the
> struct is statically declared and defined only once, and in the same
> place, we could easily turn this into
>
> static const struct {
>char alias[24];
>char param[20];
> };
>
> and get rid of all the overhead. The only slightly annoying thing is
> that the array sizes need to be kept in sync with the largest instance
> appearing in the array, but this is easy when the struct type is
> declared in the same place where its only instance is defined.

Fair enough. I personally find the result butt-ugly, but I agree
that it certainly saves some memory. Does the following work for
you? I can even give symbolic names to the various constants (how
generous of me! ;-).



To be honest, I was anticipating more of a discussion, but this looks
reasonable to me.


It looked like a reasonable ask: all the strings are completely useless
once the kernel has booted, and I'm the first to moan that I can't boot
an arm64 kernel with less than 60MB of RAM (OK, it's a pretty bloated
kernel...).


Does 'charfeature[80];' really need 80 bytes though?


It really needs 75 bytes, because of this:

{ "arm64.nopauth",
  "id_aa64isar1.gpi=0 id_aa64isar1.gpa=0 "
  "id_aa64isar1.api=0 id_aa64isar1.apa=0"},

80 is a round enough number.

Thanks,

M.
--
Jazz is not dead. It just smells funny...


Re: [PATCH v6 08/14] mm/gup: do not migrate zero page

2021-01-25 Thread Jason Gunthorpe
On Wed, Jan 20, 2021 at 09:26:41AM -0500, Pavel Tatashin wrote:

> I thought about this, and it would code a little cleaner. But, the
> reason I did not is because zero_page is perfectly pinnable, it is not
> pinnable only when it is in a movable zone (and it should not be in a
> movable zones for other reasons as well), but that is another bug that
> needs to be resolved, and once that bug is resolved this condition can
> be removed from gup migration.

My point is you've defined the zero page to be pinnable no matter what
zone it is in, so is_pinnable(zero_page) == true

Jason


Re: [PATCH 1/5] rtlwifi: rtl_pci: fix bool comparison in expressions

2021-01-25 Thread Kalle Valo
Aditya Srivastava  wrote:

> There are certain conditional expressions in rtl_pci, where a boolean
> variable is compared with true/false, in forms such as (foo == true) or
> (false != bar), which does not comply with checkpatch.pl (CHECK:
> BOOL_COMPARISON), according to which boolean variables should be
> themselves used in the condition, rather than comparing with true/false
> 
> E.g., in drivers/net/wireless/realtek/rtlwifi/ps.c,
> "if (find_p2p_ie == true)" can be replaced with "if (find_p2p_ie)"
> 
> Replace all such expressions with the bool variables appropriately
> 
> Signed-off-by: Aditya Srivastava 

5 patches applied to wireless-drivers-next.git, thanks.

d8cbaa3de403 rtlwifi: rtl_pci: fix bool comparison in expressions
f7c76283fc5f rtlwifi: rtl8192c-common: fix bool comparison in expressions
64338f0dfd6a rtlwifi: rtl8188ee: fix bool comparison in expressions
33ae4623d544 rtlwifi: rtl8192se: fix bool comparison in expressions
9264cabc1204 rtlwifi: rtl8821ae: fix bool comparison in expressions

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20210110121525.2407-2-yashsri...@gmail.com/

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



  1   2   3   4   5   6   7   8   9   10   >