[PATCH] hwmon: corsair-cpro: fix ccp_probe, add delay

2020-08-16 Thread Marius Zachmann
Possibly because of the changes in usbhid/hid-core.c the first
raw input report is not received during ccp_probe function and it will timeout.
I am not sure, whether this behaviour is expected after hid_device_io_start or 
if I
am missing something.
As a solution this adds msleep(50) to ccp_probe so that all initial input 
reports can
be received.

Signed-off-by: Marius Zachmann 
---
 drivers/hwmon/corsair-cpro.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/corsair-cpro.c b/drivers/hwmon/corsair-cpro.c
index 591929ec217a..6359409e6c71 100644
--- a/drivers/hwmon/corsair-cpro.c
+++ b/drivers/hwmon/corsair-cpro.c
@@ -10,6 +10,7 @@

 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -513,8 +514,8 @@ static int ccp_probe(struct hid_device *hdev, const struct 
hid_device_id *id)
init_completion(&ccp->wait_input_report);

hid_device_io_start(hdev);
+   msleep(50); /* make sure, events can be received */

-   /* temp and fan connection status only updates when device is powered 
on */
ret = get_temp_cnct(ccp);
if (ret)
goto out_hw_close;
--
2.28.0


Re: [PATCH] parisc: fix PMD pages allocation by restoring pmd_alloc_one()

2020-08-16 Thread Mike Rapoport
On Sun, Aug 16, 2020 at 10:52:21AM -0700, Linus Torvalds wrote:
> On Sun, Aug 16, 2020 at 10:43 AM Mike Rapoport  wrote:
> >
> > I presume this is going via parisc tree, do you mind fixing up
> > while applying?
> 
> I'll take it directly to not miss rc1, and I'll fix up the typo too.

Thanks!

>   Linus

-- 
Sincerely yours,
Mike.


Re: [PATCHv4 0/6] Add initial genpd support for omap PRM driver

2020-08-16 Thread Tony Lindgren
Hi Santosh,

* Tony Lindgren  [200702 18:46]:
> Hi all,
> 
> Here's v4 set of patches to add genpd support to the PRM (Power and Reset
> Module) driver.
> 
> Initially we just add one hardware accelerator power domain for sgx,
> and one interconnect instance for l4_abe. The rest of the SoC specific
> domain data is probably best added one SoC at a time based on generated
> data.

Care to ack some of these patches? I'd like to get this into Linux next
for v5.10 :)

Regards,

Tony


> Changes since v3:
> - Drop the unnecessary __maybe_unused as that's no longer needed
> 
> Changes since v2:
> 
> - Update binding to clarify a single power domain provider
> 
> - Unwrap generic domain configrations for __maybe_unused
> 
> Changes since v1:
> 
> - Dropped clocks from the binding and prm driver as there's no need
>   for them as pointed out by Tero
> 
> - Add checking for domain transition bit in pwrstst register as
>   pointed out by Tero
> 
> - Add omap_prm_domain_show_state() for CONFIG_DEBUG
> 
> 
> Tony Lindgren (6):
>   dt-bindings: omap: Update PRM binding for genpd
>   soc: ti: omap-prm: Add basic power domain support
>   soc: ti: omap-prm: Configure sgx power domain for am3 and am4
>   soc: ti: omap-prm: Configure omap4 and 5 l4_abe power domain
>   ARM: dts: Configure am3 and am4 sgx for genpd and drop platform data
>   ARM: dts: Configure omap4 and 5 l4_abe for genpd and drop platform
> data
> 
>  .../devicetree/bindings/arm/omap/prm-inst.txt |   2 +
>  arch/arm/boot/dts/am33xx.dtsi |   2 +
>  arch/arm/boot/dts/am4372.dtsi |   2 +
>  arch/arm/boot/dts/omap4-l4-abe.dtsi   |   6 +-
>  arch/arm/boot/dts/omap4.dtsi  |   6 +
>  arch/arm/boot/dts/omap5-l4-abe.dtsi   |   6 +-
>  arch/arm/boot/dts/omap5.dtsi  |   6 +
>  arch/arm/mach-omap2/Kconfig   |   1 +
>  .../omap_hwmod_33xx_43xx_interconnect_data.c  |  16 -
>  .../omap_hwmod_33xx_43xx_ipblock_data.c   |  40 ---
>  arch/arm/mach-omap2/omap_hwmod_33xx_data.c|   2 -
>  arch/arm/mach-omap2/omap_hwmod_43xx_data.c|   2 -
>  arch/arm/mach-omap2/omap_hwmod_44xx_data.c|  33 ---
>  arch/arm/mach-omap2/omap_hwmod_54xx_data.c|  31 --
>  drivers/soc/ti/omap_prm.c | 274 +-
>  15 files changed, 298 insertions(+), 131 deletions(-)
> 
> -- 
> 2.27.0
> 


Re: [PATCH] block: don't read block device if it's invalid

2020-08-16 Thread Christoph Hellwig
On Tue, Aug 11, 2020 at 09:43:06AM -0400, Xianting Tian wrote:
> We found several processes in 'D' state after nvme device hot-removed,
> The call trace as below, we can see process 848 got lock 'bdev->bd_mutex'
> in blkdev_reread_part(), but scheduled out due to wait for IO done. But
> the IO won't be completed as the device is hot-removed. Then it caused
> the lock 'bdev->bd_mutex' can't be unlocked. As a result, it caused
> other processes, which need to get the same lock 'bdev->bd_mutex',
> blocked on this lock.
> 
> When nvme device hot-removed, kernel will start a thread to handle the
> task of nvme device removing, as the call trace of process 504 shows
> below. I listed the call trace of nvme_kill_queues() in detail as below,
> we can see 'NVME_NS_DEAD' is set, then when executing
> nvme_revalidate_disk(), it found 'NVME_NS_DEAD' is set and
> 'set_capacity(disk, 0)' will be called to set disk capacity to 0.
> nvme_kill_queues()
> if (test_and_set_bit(NVME_NS_DEAD, &ns->flags)) return;
> revalidate_disk(disk)
> disk->fops->revalidate_disk(disk) <=for nvme device, 
> revalidate_disk=nvme_revalidate_disk()
>  mutex_lock(&bdev->bd_mutex)
> 
> This patch is to reduce the probability of such problem. Before getting
> the lock of 'bdev->bd_mutex' in blkdev_reread_part(), add the code to
> check if the capacity of the disk is 0, just return. Then we can avoid
> the happen of the issue:
> nvme device is hot-removed, and its capacity is alreday set to 0; then
> if there is process like 848 want to read the device, it will return
> directly in blkdev_reread_part(), then it will not get the lock
> "bdev->bd_mutex", which can't be unlocked by the process itself as IO
> can't be completed.

We need to fix this for real, as you stated at best this reduces the
window that the race can happen.

I think our main problem is that due to bd_mutex we can't update the
block device size from arbitrary context.  If we instead add an irqsave
spinlock just for the size we'd get rid of the limitation and can stop
papering over the problem.  Give m a little time to try to do that.


[PATCH V3] arm64: dts: qcom: sc7180: Add bandwidth votes for eMMC and SDcard

2020-08-16 Thread Shaik Sajida Bhanu
From: Pradeep P V K 

Add the bandwidth domain supporting performance state and
the corresponding OPP tables for the sdhc device on sc7180.

Signed-off-by: Pradeep P V K 
Signed-off-by: Shaik Sajida Bhanu 
---

This change is depends on the below patch series:
https://lore.kernel.org/patchwork/patch/1278294/

Change since V2:
- Included tag in the of innerconnect-cells for sdhc nodes in-tune with
  https://lore.kernel.org/patchwork/patch/1278294/

Changes since V1:
- Included Pradeep Pragalapati signoff.
- Removed dependency patch list as those patches already merged
  on linux-next.
---
 arch/arm64/boot/dts/qcom/sc7180.dtsi | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sc7180.dtsi 
b/arch/arm64/boot/dts/qcom/sc7180.dtsi
index 68f9894..e5a7d88 100644
--- a/arch/arm64/boot/dts/qcom/sc7180.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7180.dtsi
@@ -684,6 +684,9 @@
clocks = <&gcc GCC_SDCC1_APPS_CLK>,
<&gcc GCC_SDCC1_AHB_CLK>;
clock-names = "core", "iface";
+   interconnects = <&aggre1_noc MASTER_EMMC 0 &mc_virt 
SLAVE_EBI1 0>,
+   <&gem_noc MASTER_APPSS_PROC 0 &config_noc 
SLAVE_EMMC_CFG 0>;
+   interconnect-names = "sdhc-ddr","cpu-sdhc";
power-domains = <&rpmhpd SC7180_CX>;
operating-points-v2 = <&sdhc1_opp_table>;
 
@@ -704,11 +707,15 @@
opp-1 {
opp-hz = /bits/ 64 <1>;
required-opps = <&rpmhpd_opp_low_svs>;
+   opp-peak-kBps = <10 10>;
+   opp-avg-kBps = <10 5>;
};
 
opp-38400 {
opp-hz = /bits/ 64 <38400>;
required-opps = <&rpmhpd_opp_svs_l1>;
+   opp-peak-kBps = <60 90>;
+   opp-avg-kBps = <261438 30>;
};
};
};
@@ -2476,6 +2483,10 @@
clocks = <&gcc GCC_SDCC2_APPS_CLK>,
<&gcc GCC_SDCC2_AHB_CLK>;
clock-names = "core", "iface";
+
+   interconnects = <&aggre1_noc MASTER_SDCC_2 0 &mc_virt 
SLAVE_EBI1 0>,
+   <&gem_noc MASTER_APPSS_PROC 0 &config_noc 
SLAVE_SDCC_2 0>;
+   interconnect-names = "sdhc-ddr","cpu-sdhc";
power-domains = <&rpmhpd SC7180_CX>;
operating-points-v2 = <&sdhc2_opp_table>;
 
@@ -2489,11 +2500,15 @@
opp-1 {
opp-hz = /bits/ 64 <1>;
required-opps = <&rpmhpd_opp_low_svs>;
+   opp-peak-kBps = <16 10>;
+   opp-avg-kBps = <8 5>;
};
 
opp-20200 {
opp-hz = /bits/ 64 <20200>;
required-opps = <&rpmhpd_opp_svs_l1>;
+   opp-peak-kBps = <20 12>;
+   opp-avg-kBps = <10 6>;
};
};
};
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation



[PATCH v5] kthread: Add debugobject support

2020-08-16 Thread Qianli Zhao
From: Qianli Zhao 

Add debugobject support to track the life time of kthread_work
which is used to detect reinitialization/free active object problems
Add kthread_init_work_onstack()/kthread_init_delayed_work_onstack() for
kthread onstack support

If we reinitialize a kthread_work that has been activated,
this will cause delayed_work_list/work_list corruption.
enable this config,there is an chance to fixup these errors
or WARNING the wrong use of kthread_work

[30858.395766] list_del corruption. next->prev should be ffe388ebbf88, but 
was ffe388ebb588
[30858.395788] WARNING: CPU: 2 PID: 387 at kernel/msm-4.19/lib/list_debug.c:56 
__list_del_entry_valid+0xc8/0xd0
...
[30858.395906] Call trace:
[30858.395909]  __list_del_entry_valid+0xc8/0xd0
[30858.395912]  __kthread_cancel_work_sync+0x98/0x138
[30858.395915]  kthread_cancel_delayed_work_sync+0x10/0x20
[30858.395917]  sde_encoder_resource_control+0xe8/0x12c0
[30858.395920]  sde_encoder_prepare_for_kickoff+0x5dc/0x2008
[30858.395923]  sde_crtc_commit_kickoff+0x280/0x890
[30858.395925]  sde_kms_commit+0x16c/0x278
[30858.395928]  complete_commit+0x3c4/0x760
[30858.395931]  _msm_drm_commit_work_cb+0xec/0x1e0
[30858.395933]  kthread_worker_fn+0xf8/0x190
[30858.395935]  kthread+0x118/0x128
[30858.395938]  ret_from_fork+0x10/0x18

crash> struct kthread_worker.delayed_work_list 0xffe3893925f0
 [ffe389392620] delayed_work_list = {
next = 0xffe388ebbf88,
prev = 0xffe388ebb588
  }
crash> list 0xffe388ebbf88
ffe388ebbf88

Signed-off-by: Qianli Zhao 
---
V5:
- Fix format error checked by checkpatch.pl 

V4:
- Changelog update
- Add comment for KWORK_ENTRY_STATIC
- Code format modification 
- Check worker availability early in kthread_flush_work

V3:
- changelog update
- add fixup_assert_init support
- move debug_kwork_activate/debug_kwork_deactivate before list operation
- name the kconfig CONFIG_DEBUG_OBJECTS_KTHREAD_WORK
- use kthread_init_work_onstack/destroy_kwork_on_stack when kthread_work used 
on stack
- __init_kwork before clear kthread_work in kthread_init_work
---
 include/linux/kthread.h |  30 ++-
 include/linux/poison.h  |   4 ++
 kernel/kthread.c| 136 ++--
 lib/Kconfig.debug   |  10 
 4 files changed, 174 insertions(+), 6 deletions(-)

diff --git a/include/linux/kthread.h b/include/linux/kthread.h
index 65b81e0..706302b 100644
--- a/include/linux/kthread.h
+++ b/include/linux/kthread.h
@@ -108,6 +108,17 @@ struct kthread_delayed_work {
struct timer_list timer;
 };
 
+#ifdef CONFIG_DEBUG_OBJECTS_KTHREAD_WORK
+extern void __init_kwork(struct kthread_work *kwork, int onstack);
+extern void destroy_kwork_on_stack(struct kthread_work *kwork);
+extern void destroy_delayed_kwork_on_stack(struct kthread_delayed_work 
*kdwork);
+#else
+static inline void __init_kwork(struct kthread_work *kwork, int onstack) { }
+static inline void destroy_kwork_on_stack(struct kthread_work *kwork) { }
+static inline void destroy_delayed_kwork_on_stack(struct kthread_delayed_work 
*kdwork) { }
+#endif
+
+
 #define KTHREAD_WORKER_INIT(worker){   \
.lock = __RAW_SPIN_LOCK_UNLOCKED((worker).lock),\
.work_list = LIST_HEAD_INIT((worker).work_list),\
@@ -115,7 +126,7 @@ struct kthread_delayed_work {
}
 
 #define KTHREAD_WORK_INIT(work, fn){   \
-   .node = LIST_HEAD_INIT((work).node),\
+   .node = { .next = KWORK_ENTRY_STATIC }, \
.func = (fn),   \
}
 
@@ -159,6 +170,15 @@ extern void __kthread_init_worker(struct kthread_worker 
*worker,
 
 #define kthread_init_work(work, fn)\
do {\
+   __init_kwork(work, 0);  
\
+   memset((work), 0, sizeof(struct kthread_work)); \
+   INIT_LIST_HEAD(&(work)->node);  \
+   (work)->func = (fn);\
+   } while (0)
+
+#define kthread_init_work_onstack(work, fn)
\
+   do {\
+   __init_kwork(work, 1);  
\
memset((work), 0, sizeof(struct kthread_work)); \
INIT_LIST_HEAD(&(work)->node);  \
(work)->func = (fn);\
@@ -172,6 +192,14 @@ extern void __kthread_init_worker(struct kthread_worker 
*worker,
 TIMER_IRQSAFE);\
} while (0)
 
+#define kthread_init_delayed_work_onstack(dwork, fn)   
\
+   do {

Re: [PATCH v2] soundwire: master: enable pm runtime

2020-08-16 Thread Vinod Koul
On 27-07-20, 05:59, Bard Liao wrote:
> The hierarchy of soundwire devices is platform device -> M device -> S
> device. A S device is physically attached on the platform device. So the
> platform device should be resumed when a S device is resumed. As the
> bridge of platform device and S device, we have to implement runtime pm
> on M driver. We have set runtime pm ops in M driver already, but still
> need to enable runtime pm.

Applied, thanks

-- 
~Vinod


Re: [PATCH v8 2/2] phy: Add USB3 PHY support for Intel LGM SoC

2020-08-16 Thread Ramuthevar, Vadivel MuruganX

Hi Felipe,

On 17/8/2020 2:08 pm, Felipe Balbi wrote:

Hi

On Mon, Aug 17, 2020 at 6:13 AM Ramuthevar,Vadivel MuruganX

diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index c27408e4daae..90030ff299eb 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -1,4 +1,4 @@
-# SPDX-License-Identifier: GPL-2.0
+PDX-License-Identifier: GPL-2.0


you didn't try to compile your patch

Good catch, Thank you so much!!
after compiled by mistakenly removed 'S'.

Regards
Vadivel




Re: [PATCH RESEND 5/5] block: Remove __blk_mq_sched_bio_merge() helper

2020-08-16 Thread Christoph Hellwig
On Mon, Aug 17, 2020 at 12:09:19PM +0800, Baolin Wang wrote:
> The blk_mq_sched_bio_merge() just wrap the __blk_mq_sched_bio_merge(), and
> no other places will use __blk_mq_sched_bio_merge(). Thus we can combine
> these 2 similar functions into one function.

I think the idea was to avoid the function call for the nomerges fast
path.  Not sure if that is really worth it.


Re: [PATCH RESEND 4/5] block: Remove blk_mq_attempt_merge() function

2020-08-16 Thread Christoph Hellwig
On Mon, Aug 17, 2020 at 12:09:18PM +0800, Baolin Wang wrote:
>   unsigned int nr_segs)
>  {
> @@ -447,7 +425,16 @@ bool __blk_mq_sched_bio_merge(struct request_queue *q, 
> struct bio *bio,
>   !list_empty_careful(&ctx->rq_lists[type])) {
>   /* default per sw-queue merge */
>   spin_lock(&ctx->lock);
> - ret = blk_mq_attempt_merge(q, hctx, ctx, bio, nr_segs);
> + /*
> +  * Reverse check our software queue for entries that we could
> +  * potentially merge with. Currently includes a hand-wavy stop
> +  * count of 8, to not spend too much time checking for merges.
> +  */
> + if (blk_mq_bio_list_merge(q, &ctx->rq_lists[type], bio, 
> nr_segs)) {
> + ctx->rq_merged++;
> + ret = true;
> + }
> +
>   spin_unlock(&ctx->lock);

This adds an overly long line.  That being said the whole thing could
be nicely simplified to:

...

if (e && e->type->ops.bio_merge)
return e->type->ops.bio_merge(hctx, bio, nr_segs);

if (!(hctx->flags & BLK_MQ_F_SHOULD_MERGE) ||
list_empty_careful(&ctx->rq_lists[hctx->type]))
return false;

/*
 * Reverse check our software queue for entries that we could
 * potentially merge with. Currently includes a hand-wavy stop count of
 * 8, to not spend too much time checking for merges.
 */
spin_lock(&ctx->lock);
ret = blk_mq_bio_list_merge(q, &ctx->rq_lists[type], bio, nr_segs);
if (ret)
ctx->rq_merged++;
spin_unlock(&ctx->lock);

Also I think it would make sense to move the locking into
blk_mq_bio_list_merge.


Re: [PATCH] upcall: Remove unneeded variable insize

2020-08-16 Thread kernel test robot
Hi Xu,

Thank you for the patch! Yet something to improve:

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

url:
https://github.com/0day-ci/linux/commits/Xu-Wang/upcall-Remove-unneeded-variable-insize/20200817-112244
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
9123e3a74ec7b934a4a099e98af6a61c2f80bbf5
config: x86_64-randconfig-a012-20200817 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 
de71b46a519db014ce906a39f8a0e1b235ef1568)
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

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

All errors (new ones prefixed by >>):

>> fs/coda/upcall.c:483:2: error: use of undeclared identifier 'insize'
   UPARG(CODA_IOCTL);
   ^
   fs/coda/upcall.c:63:44: note: expanded from macro 'UPARG'
   inp = (union inputArgs *)alloc_upcall(op, insize); \
 ^
>> fs/coda/upcall.c:483:2: error: use of undeclared identifier 'insize'
   fs/coda/upcall.c:66:19: note: expanded from macro 'UPARG'
   outsize = insize; \
 ^
   2 errors generated.

# 
https://github.com/0day-ci/linux/commit/e126bb2bc1e15e86a4267e92df88f4987d01b358
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Xu-Wang/upcall-Remove-unneeded-variable-insize/20200817-112244
git checkout e126bb2bc1e15e86a4267e92df88f4987d01b358
vim +/insize +483 fs/coda/upcall.c

^1da177e4c3f41 Linus Torvalds   2005-04-16  473  
^1da177e4c3f41 Linus Torvalds   2005-04-16  474  
^1da177e4c3f41 Linus Torvalds   2005-04-16  475  int venus_pioctl(struct 
super_block *sb, struct CodaFid *fid,
^1da177e4c3f41 Linus Torvalds   2005-04-16  476  unsigned int 
cmd, struct PioctlData *data)
^1da177e4c3f41 Linus Torvalds   2005-04-16  477  {
^1da177e4c3f41 Linus Torvalds   2005-04-16  478  union inputArgs *inp;
^1da177e4c3f41 Linus Torvalds   2005-04-16  479  union outputArgs 
*outp;  
e126bb2bc1e15e Xu Wang  2020-08-17  480 int outsize, error;
^1da177e4c3f41 Linus Torvalds   2005-04-16  481 int iocsize;
^1da177e4c3f41 Linus Torvalds   2005-04-16  482  
^1da177e4c3f41 Linus Torvalds   2005-04-16 @483 UPARG(CODA_IOCTL);
^1da177e4c3f41 Linus Torvalds   2005-04-16  484  
^1da177e4c3f41 Linus Torvalds   2005-04-16  485  /* build packet for 
Venus */
^1da177e4c3f41 Linus Torvalds   2005-04-16  486  if (data->vi.in_size > 
VC_MAXDATASIZE) {
^1da177e4c3f41 Linus Torvalds   2005-04-16  487 error = -EINVAL;
^1da177e4c3f41 Linus Torvalds   2005-04-16  488 goto exit;
^1da177e4c3f41 Linus Torvalds   2005-04-16  489  }
^1da177e4c3f41 Linus Torvalds   2005-04-16  490  
^1da177e4c3f41 Linus Torvalds   2005-04-16  491  if (data->vi.out_size 
> VC_MAXDATASIZE) {
^1da177e4c3f41 Linus Torvalds   2005-04-16  492 error = -EINVAL;
^1da177e4c3f41 Linus Torvalds   2005-04-16  493 goto exit;
^1da177e4c3f41 Linus Torvalds   2005-04-16  494 }
^1da177e4c3f41 Linus Torvalds   2005-04-16  495  
^1da177e4c3f41 Linus Torvalds   2005-04-16  496  inp->coda_ioctl.VFid = 
*fid;
^1da177e4c3f41 Linus Torvalds   2005-04-16  497  
^1da177e4c3f41 Linus Torvalds   2005-04-16  498  /* the cmd field was 
mutated by increasing its size field to
^1da177e4c3f41 Linus Torvalds   2005-04-16  499   * reflect the path 
and follow args. We need to subtract that
^1da177e4c3f41 Linus Torvalds   2005-04-16  500   * out before sending 
the command to Venus.  */
^1da177e4c3f41 Linus Torvalds   2005-04-16  501  inp->coda_ioctl.cmd = 
(cmd & ~(PIOCPARM_MASK << 16));  
^1da177e4c3f41 Linus Torvalds   2005-04-16  502  iocsize = ((cmd >> 16) 
& PIOCPARM_MASK) - sizeof(char *) - sizeof(int);
^1da177e4c3f41 Linus Torvalds   2005-04-16  503  inp->coda_ioctl.cmd |= 
(iocsize & PIOCPARM_MASK) <<16; 
^1da177e4c3f41 Linus Torvalds   2005-04-16  504  
^1da177e4c3f41 Linus Torvalds   2005-04-16  505  /* 
in->coda_ioctl.rwflag = flag; */
^1da177e4c3f41 Linus Torvalds   2005-04-16  506  inp->coda_ioctl.len = 
data->vi.in_size;
^1da177e4c3f41 Linus Torvalds   2005-04-16  507  inp->coda_ioctl.data = 
(char *)(IN

[PATCH] soc: qcom: socinfo: add soc id for IPQ6018

2020-08-16 Thread Kathiravan T
Add the SoC ID for IPQ6018 variant.

Signed-off-by: Kathiravan T 
---
[V2]:
- Rebased on v5.9-rc1

 drivers/soc/qcom/socinfo.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index e19102f46302..2b28667e1c66 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -223,6 +223,7 @@ static const struct soc_id soc_id[] = {
{ 321, "SDM845" },
{ 341, "SDA845" },
{ 356, "SM8250" },
+   { 402, "IPQ6018" },
 };
 
 static const char *socinfo_machine(struct device *dev, unsigned int id)
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation



RE: [PATCH v6 11/15] vfio/type1: Allow invalidating first-level/stage IOMMU cache

2020-08-16 Thread Liu, Yi L
Hi Eric,

> From: Auger Eric 
> Sent: Sunday, August 16, 2020 7:35 PM
> 
> Hi Yi,
> 
> On 7/28/20 8:27 AM, Liu Yi L wrote:
> > This patch provides an interface allowing the userspace to invalidate
> > IOMMU cache for first-level page table. It is required when the first
> > level IOMMU page table is not managed by the host kernel in the nested
> > translation setup.
> >
> > Cc: Kevin Tian 
> > CC: Jacob Pan 
> > Cc: Alex Williamson 
> > Cc: Eric Auger 
> > Cc: Jean-Philippe Brucker 
> > Cc: Joerg Roedel 
> > Cc: Lu Baolu 
> > Signed-off-by: Liu Yi L 
> > Signed-off-by: Eric Auger 
> > Signed-off-by: Jacob Pan 
> > ---
> > v1 -> v2:
> > *) rename from "vfio/type1: Flush stage-1 IOMMU cache for nesting type"
> > *) rename vfio_cache_inv_fn() to vfio_dev_cache_invalidate_fn()
> > *) vfio_dev_cache_inv_fn() always successful
> > *) remove VFIO_IOMMU_CACHE_INVALIDATE, and reuse
> VFIO_IOMMU_NESTING_OP
> > ---
> >  drivers/vfio/vfio_iommu_type1.c | 42
> +
> >  include/uapi/linux/vfio.h   |  3 +++
> >  2 files changed, 45 insertions(+)
> >
> > diff --git a/drivers/vfio/vfio_iommu_type1.c
> > b/drivers/vfio/vfio_iommu_type1.c index 245436e..bf95a0f 100644
> > --- a/drivers/vfio/vfio_iommu_type1.c
> > +++ b/drivers/vfio/vfio_iommu_type1.c
> > @@ -3056,6 +3056,45 @@ static long vfio_iommu_handle_pgtbl_op(struct
> vfio_iommu *iommu,
> > return ret;
> >  }
> >
> > +static int vfio_dev_cache_invalidate_fn(struct device *dev, void
> > +*data) {
> > +   struct domain_capsule *dc = (struct domain_capsule *)data;
> > +   unsigned long arg = *(unsigned long *)dc->data;
> > +
> > +   iommu_uapi_cache_invalidate(dc->domain, dev, (void __user *)arg);
> > +   return 0;
> > +}
> > +
> > +static long vfio_iommu_invalidate_cache(struct vfio_iommu *iommu,
> > +   unsigned long arg)
> > +{
> > +   struct domain_capsule dc = { .data = &arg };
> > +   struct iommu_nesting_info *info;
> > +   int ret;
> > +
> > +   mutex_lock(&iommu->lock);
> > +   /*
> > +* Cache invalidation is required for any nesting IOMMU,
> So why do we expose the IOMMU_NESTING_FEAT_CACHE_INVLD capability? :-)

it's a stale comment. should be removed. :-)

> > +* so no need to check system-wide PASID support.
> > +*/
> > +   info = iommu->nesting_info;
> > +   if (!info || !(info->features & IOMMU_NESTING_FEAT_CACHE_INVLD)) {
> > +   ret = -EOPNOTSUPP;
> > +   goto out_unlock;
> > +   }
> > +
> > +   ret = vfio_get_nesting_domain_capsule(iommu, &dc);
> > +   if (ret)
> > +   goto out_unlock;
> > +
> > +   iommu_group_for_each_dev(dc.group->iommu_group, &dc,
> > +vfio_dev_cache_invalidate_fn);
> > +
> > +out_unlock:
> > +   mutex_unlock(&iommu->lock);
> > +   return ret;
> > +}
> > +
> >  static long vfio_iommu_type1_nesting_op(struct vfio_iommu *iommu,
> > unsigned long arg)
> >  {
> > @@ -3078,6 +3117,9 @@ static long vfio_iommu_type1_nesting_op(struct
> vfio_iommu *iommu,
> > case VFIO_IOMMU_NESTING_OP_UNBIND_PGTBL:
> > ret = vfio_iommu_handle_pgtbl_op(iommu, false, arg + minsz);
> > break;
> > +   case VFIO_IOMMU_NESTING_OP_CACHE_INVLD:
> > +   ret = vfio_iommu_invalidate_cache(iommu, arg + minsz);
> > +   break;
> > default:
> > ret = -EINVAL;
> > }
> > diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
> > index 9501cfb..48e2fb5 100644
> > --- a/include/uapi/linux/vfio.h
> > +++ b/include/uapi/linux/vfio.h
> > @@ -1225,6 +1225,8 @@ struct vfio_iommu_type1_pasid_request {
> >   * +-+---+
> >   * | UNBIND_PGTBL|  struct iommu_gpasid_bind_data|
> >   *
> > +-+---+
> > + * | CACHE_INVLD |  struct iommu_cache_invalidate_info   |
> > + *
> > + +-+---+
> >   *
> >   * returns: 0 on success, -errno on failure.
> >   */
> > @@ -1237,6 +1239,7 @@ struct vfio_iommu_type1_nesting_op {
> >
> >  #define VFIO_IOMMU_NESTING_OP_BIND_PGTBL   (0)
> >  #define VFIO_IOMMU_NESTING_OP_UNBIND_PGTBL (1)
> > +#define VFIO_IOMMU_NESTING_OP_CACHE_INVLD  (2)
> According to my previous comment, you may refine VFIO_NESTING_OP_MASK too

yes, I've noticed it. also replied in patch 10/15.

Regards,
Yi Liu

> Thanks
> 
> Eric
> >
> >  #define VFIO_IOMMU_NESTING_OP  _IO(VFIO_TYPE, VFIO_BASE + 19)
> >
> >



RE: [PATCH v6 10/15] vfio/type1: Support binding guest page tables to PASID

2020-08-16 Thread Liu, Yi L
Hi Eric,

> From: Auger Eric 
> Sent: Sunday, August 16, 2020 7:29 PM
> 
> Hi Yi,
> 
> On 7/28/20 8:27 AM, Liu Yi L wrote:
> > Nesting translation allows two-levels/stages page tables, with 1st level
> > for guest translations (e.g. GVA->GPA), 2nd level for host translations
> > (e.g. GPA->HPA). This patch adds interface for binding guest page tables
> > to a PASID. This PASID must have been allocated by the userspace before
> > the binding request.
> >
> > Cc: Kevin Tian 
> > CC: Jacob Pan 
> > Cc: Alex Williamson 
> > Cc: Eric Auger 
> > Cc: Jean-Philippe Brucker 
> > Cc: Joerg Roedel 
> > Cc: Lu Baolu 
> > Signed-off-by: Jean-Philippe Brucker 
> > Signed-off-by: Liu Yi L 
> > Signed-off-by: Jacob Pan 
> > ---
> > v5 -> v6:
> > *) dropped vfio_find_nesting_group() and add 
> > vfio_get_nesting_domain_capsule().
> >per comment from Eric.
> > *) use iommu_uapi_sva_bind/unbind_gpasid() and iommu_sva_unbind_gpasid() in
> >linux/iommu.h for userspace operation and in-kernel operation.
> >
> > v3 -> v4:
> > *) address comments from Alex on v3
> >
> > v2 -> v3:
> > *) use __iommu_sva_unbind_gpasid() for unbind call issued by VFIO
> >https://lore.kernel.org/linux-iommu/1592931837-58223-6-git-send-email-
> jacob.jun@linux.intel.com/
> >
> > v1 -> v2:
> > *) rename subject from "vfio/type1: Bind guest page tables to host"
> > *) remove VFIO_IOMMU_BIND, introduce VFIO_IOMMU_NESTING_OP to support
> bind/
> >unbind guet page table
> > *) replaced vfio_iommu_for_each_dev() with a group level loop since this
> >series enforces one group per container w/ nesting type as start.
> > *) rename vfio_bind/unbind_gpasid_fn() to vfio_dev_bind/unbind_gpasid_fn()
> > *) vfio_dev_unbind_gpasid() always successful
> > *) use vfio_mm->pasid_lock to avoid race between PASID free and page table
> >bind/unbind
> > ---
> >  drivers/vfio/vfio_iommu_type1.c | 161
> 
> >  drivers/vfio/vfio_pasid.c   |  26 +++
> >  include/linux/vfio.h|  20 +
> >  include/uapi/linux/vfio.h   |  31 
> >  4 files changed, 238 insertions(+)
> >
> > diff --git a/drivers/vfio/vfio_iommu_type1.c 
> > b/drivers/vfio/vfio_iommu_type1.c
> > index ea89c7c..245436e 100644
> > --- a/drivers/vfio/vfio_iommu_type1.c
> > +++ b/drivers/vfio/vfio_iommu_type1.c
> > @@ -149,6 +149,36 @@ struct vfio_regions {
> >  #define DIRTY_BITMAP_PAGES_MAX  ((u64)INT_MAX)
> >  #define DIRTY_BITMAP_SIZE_MAX
> DIRTY_BITMAP_BYTES(DIRTY_BITMAP_PAGES_MAX)
> >
> > +struct domain_capsule {
> > +   struct vfio_group *group;
> > +   struct iommu_domain *domain;
> > +   void *data;
> You may add a bool indicating whether the data is a user pointer or the
> direct IOMMU UAPI struct.

yes, it is helpful.

> > +};
> > +
> > +/* iommu->lock must be held */
> > +static int vfio_get_nesting_domain_capsule(struct vfio_iommu *iommu,
> > +  struct domain_capsule *dc)
> I would rename the function into vfio_prepare_nesting_domain_capsule

got it. :-)

> > +{
> > +   struct vfio_domain *domain = NULL;
> > +   struct vfio_group *group = NULL;
> > +
> > +   if (!iommu->nesting_info)
> > +   return -EINVAL;
> > +
> > +   /*
> > +* Only support singleton container with nesting type.
> > +* If nesting_info is non-NULL, the conatiner should
> s/should/is here and below
> s/conatiner/container

got it. thanks.

> > +* be non-empty. Also domain should be non-empty.
> > +*/
> > +   domain = list_first_entry(&iommu->domain_list,
> > + struct vfio_domain, next);
> > +   group = list_first_entry(&domain->group_list,
> > +struct vfio_group, next);
> > +   dc->group = group;
> > +   dc->domain = domain->domain;
> dc->user = true;?

yep.

> > +   return 0;
> > +}
> > +
> >  static int put_pfn(unsigned long pfn, int prot);
> >
> >  static struct vfio_group *vfio_iommu_find_iommu_group(struct vfio_iommu
> *iommu,
> > @@ -2349,6 +2379,48 @@ static int vfio_iommu_resv_refresh(struct vfio_iommu
> *iommu,
> > return ret;
> >  }
> >
> > +static int vfio_dev_bind_gpasid_fn(struct device *dev, void *data)
> > +{
> > +   struct domain_capsule *dc = (struct domain_capsule *)data;
> > +   unsigned long arg = *(unsigned long *)dc->data;
> > +
> > +   return iommu_uapi_sva_bind_gpasid(dc->domain, dev, (void __user *)arg);
> > +}
> > +
> > +static int vfio_dev_unbind_gpasid_fn(struct device *dev, void *data)
> > +{
> > +   struct domain_capsule *dc = (struct domain_capsule *)data;
> > +   unsigned long arg = *(unsigned long *)dc->data;
> > +
> > +   iommu_uapi_sva_unbind_gpasid(dc->domain, dev, (void __user *)arg);
> > +   return 0;
> > +}
> > +
> > +static int __vfio_dev_unbind_gpasid_fn(struct device *dev, void *data)
> can be removed if dc->user flag gets added

yes.

> > +{
> > +   struct domain_capsule *dc = (struct domain_capsule *)data;
> > +   struct iommu_gpasid_bind_data *unbind_data =
> > + 

Re: [PATCH v2 0/5] dmaengine: dw: Introduce non-mem peripherals optimizations

2020-08-16 Thread Vinod Koul
On 31-07-20, 23:08, Serge Semin wrote:
> After a lot of tests and thorough DW DMAC databook studying we've
> discovered that the driver can be optimized especially when it comes to
> working with non-memory peripherals.
> 
> First of all we've found out that since each DW DMAC channel can
> be synthesized with different parameters, then even when two of them
> are configured to perform the same DMA transactions they may execute them
> with different performance. Since some DMA client devices might be
> sensitive to such important parameter as performance, then it is a good
> idea to let them request only suitable DMA channels. In this patchset we
> introduce a functionality, which makes it possible by passing the DMA
> channels mask either over the "dmas" DT property or in the dw_dma_slave
> platform data descriptor.
> 
> Secondly FIFO-mode of the "FIFO readiness" criterion is more suitable for
> the pure memory DMA transfers, since it minimizes the system bus
> utilization, but causes some performance drop. When it comes to working with
> non-memory peripherals the DMA engine performance comes to the first
> place. Since normally DMA client devices keep data in internal FIFOs, any
> latency at some critical moment may cause a FIFO being overflown and
> consequently losing data. So in order to minimize a chance of the DW DMAC
> internal FIFO being a bottle neck during the DMA transfers to and from
> non-memory peripherals we propose not to use FIFO-mode for them.
> 
> Thirdly it has been discovered that using a DMA transaction length is
> redundant when calculating the destination transfer width for the
> dev-to-mem DMA communications. That shall increase performance of the DMA
> transfers with unaligned data length.
> 
> Finally there is a small optimization in the burst length setting. In
> particular we've found out, that according to the DW DMAC databoot it's
> pointless to set one for the memory peripherals since they don't have
> handshaking interface connected to the DMA controller. So we suggest to
> just ignore the burst length config when it comes to setting the memory
> peripherals up.

Applied all, thanks

-- 
~Vinod


Re: [PATCH RESEND 3/5] block: Add a new helper to attempt to merge a bio

2020-08-16 Thread Christoph Hellwig
On Mon, Aug 17, 2020 at 12:09:17PM +0800, Baolin Wang wrote:
> There are lots of duplicated code when trying to merge a bio from
> plug list and sw queue, we can introduce a new helper to attempt
> to merge a bio, which can simplify the blk_mq_bio_list_merge()
> and blk_attempt_plug_merge().

Looks sensible, but two comments:

> +enum bio_merge_status blk_attempt_bio_merge(struct request_queue *q,
> + struct request *rq,
> + struct bio *bio,
> + unsigned int nr_segs)
> +{
> + bool merged = false;
> +
> + if (!blk_rq_merge_ok(rq, bio))
> + return BIO_MERGE_NONE;
> +
> + switch (blk_try_merge(rq, bio)) {
> + case ELEVATOR_BACK_MERGE:
> + merged = bio_attempt_back_merge(rq, bio, nr_segs);
> + break;
> + case ELEVATOR_FRONT_MERGE:
> + merged = bio_attempt_front_merge(rq, bio, nr_segs);
> + break;
> + case ELEVATOR_DISCARD_MERGE:
> + merged = bio_attempt_discard_merge(q, rq, bio);
> + break;

Can't we also switch the bio_attempt_*merge helpers to return
enum bio_merge_status to simplify this a bit?

Also I think these helpers can be marked static now, although I didn't
actually apply your series, so I might have missed something.

> +++ b/block/blk-mq-sched.c
> @@ -391,31 +391,17 @@ bool blk_mq_bio_list_merge(struct request_queue *q, 
> struct list_head *list,
>  {
>   struct request *rq;
>   int checked = 8;
> + enum bio_merge_status merge;
>  
>   list_for_each_entry_reverse(rq, list, queuelist) {
> - bool merged = false;
> -
>   if (!checked--)
>   break;
>  
> + merge = blk_attempt_bio_merge(q, rq, bio, nr_segs);
> + if (merge == BIO_MERGE_NONE)
>   continue;
>  
> + return merge == BIO_MERGE_OK ? true: false;

Maybe write this a little more explicit:

switch (blk_attempt_bio_merge(q, rq, bio, nr_segs)) {
case BIO_MERGE_NONE:
continue:
case BIO_MERGE_OK:
return true;
case BIO_MERGE_FAILED:
return false;
}

>  enum elv_merge blk_try_merge(struct request *rq, struct bio *bio);
>  
> +enum bio_merge_status {
> + BIO_MERGE_OK,
> + BIO_MERGE_NONE,
> + BIO_MERGE_FAILED,
> +};
> +
> +enum bio_merge_status blk_attempt_bio_merge(struct request_queue *q,
> + struct request *rq, struct bio *bio, unsigned int nr_segs);
> +
>  int blk_dev_init(void);
>  
>  /*
> -- 
> 1.8.3.1
---end quoted text---


Re: [PATCH RESEND 2/5] block: Remove redundant blk_mq_sched_allow_merge() validation

2020-08-16 Thread Christoph Hellwig
On Mon, Aug 17, 2020 at 12:09:16PM +0800, Baolin Wang wrote:
> Only software queue and kyber IO scheduler will call blk_mq_bio_list_merge()
> to merge a bio, and kyber IO scheduler did not implement the 
> ops->allow_merge().

Please line wrap your changelogs after 73 characters.

> Thus we can remove the redundant blk_mq_sched_allow_merge() in
> blk_mq_bio_list_merge() function.

This seems potentially dangerous, and I don't think it really buys
us much.


Re: [PATCH] clk: clk-hi3670: Add CLK_IGNORE_UNUSED flag

2020-08-16 Thread Mauro Carvalho Chehab
Em Sat, 15 Aug 2020 19:33:31 -0700
Stephen Boyd  escreveu:

> Please send patches To: somebody. Sending them to nobody causes my MUA
> pain.

Ok. Should I send it to you or to someone else?
> 
> Quoting Mauro Carvalho Chehab (2020-08-14 07:16:20)
> > There are several clocks that are required for Kirin 970 to
> > work. Without them, the system hangs. However, most of
> > the clocks defined at clk-hi3670 aren't specified on its
> > device tree, nor at Hikey 970 one.
> > 
> > A few of them are defined at the Linaro's official tree
> > for Hikey 970, but, even there, distros use
> > 
> > clk_ignore_unused=true
> > 
> > as a boot option.
> > 
> > So, instead, let's modify the driver to use CLK_IGNORE_UNUSED
> > flags, removing the need for this boot parameter.
> > 
> > Signed-off-by: Mauro Carvalho Chehab 
> > ---
> >  drivers/clk/hisilicon/clk-hi3670.c | 731 +
> >  1 file changed, 425 insertions(+), 306 deletions(-)  
> 
> This is very many. Are all of these clks actually enabled out of boot
> and are getting turned off at late init?

That's a very good question. Unfortunately, I don't know.

There are some documentation at:

https://www.96boards.org/documentation/consumer/hikey/hikey970/hardware-docs/

Including schematics for HiKey 970, but it doesn't seem to show all
the clock lines, plus the clock names at the driver don't seem to match
what's there at the datasheet.

> Is there some set of clks that can be marked as CLK_IS_CRITICAL instead?

Maybe, but identifying those would require a huge amount of work. See,
this patch marks 306 clock lines with CLK_IGNORE_UNUSED:

$ git grep CLK_IGNORE_UNUSED drivers/clk/hisilicon/clk-hi3670.c|wc -l
306

At vanilla Kernel 5.8, there are 49 known clock lines:

$ git grep -E 'HI\S+CLK' arch/arm64/boot/dts/hisilicon/*70*|wc -l
49

As I'm porting several drivers in order to support DRM and hopefully USB,
this count should increase as drivers get merged.

At downstream 4.9 Kernel, there are 99 known clock lines:

$ git grep -E 'KI\S+CLK' arch/arm64/boot/dts/hisilicon/*70*|wc -l
99

In other words, there are still 207 lines that we have no clue about
them. What among those are critical or not is a very good question.


> The CLK_IGNORE_UNUSED flag shouldn't be used very much at all. Instead,
> drivers should be using the CLK_IS_CRITICAL flag. We have a lot of
> CLK_IGNORE_UNUSED in the kernel right now, but the hope is that we can
> get rid of this flag one day.

I see the point. Yet, I can't see any solution for that, except not letting 
PM to disable unused clocks on this chipset. See, the only way to use the
HiKey 970 board (which is the only one with DT bindings upstream for this
chipset) is to boot the Kernel with clk_ignore_unused=true.

Ok, if someone has enough time and some robot infrastructure that would
automatically be patching the driver, detect broken boots, and powering
down/up the device after each attempt, he could be disabling each one of 
the clock lines that are not specified at the DT, identifying the
critical ones.

Then, he may need to port more drivers, together with their DT bindings,
from the downstream tree.

That is a lot of work for, IMHO, not much gain.

Thanks,
Mauro


Re: [PATCH RESEND 1/5] block: Move bio merge related functions into blk-merge.c

2020-08-16 Thread Christoph Hellwig
On Mon, Aug 17, 2020 at 12:09:15PM +0800, Baolin Wang wrote:
> It's better to move bio merge related functions into blk-merge.c,
> which contains all merge related functions.
> 
> Signed-off-by: Baolin Wang 
> ---
>  block/blk-core.c  | 156 -
>  block/blk-merge.c | 157 
> ++
>  2 files changed, 157 insertions(+), 156 deletions(-)

Looks fine:

Reviewed-by: Christoph Hellwig 


Re: [greybus-dev] [PATCH] drivers/greybus: Use kobj_to_dev() instead

2020-08-16 Thread Viresh Kumar
On 13-08-20, 11:34, Wang Qing wrote:
> Use kobj_to_dev() instead of container_of()
> 
> Signed-off-by: Wang Qing 
> ---
>  drivers/greybus/interface.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Acked-by: Viresh Kumar 

-- 
viresh


Re: [PATCH v8 2/2] phy: Add USB3 PHY support for Intel LGM SoC

2020-08-16 Thread Felipe Balbi
Hi

On Mon, Aug 17, 2020 at 6:13 AM Ramuthevar,Vadivel MuruganX
> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> index c27408e4daae..90030ff299eb 100644
> --- a/drivers/phy/Makefile
> +++ b/drivers/phy/Makefile
> @@ -1,4 +1,4 @@
> -# SPDX-License-Identifier: GPL-2.0
> +PDX-License-Identifier: GPL-2.0

you didn't try to compile your patch

-- 
balbi


[PATCH v5 2/2] dt-bindings: mediatek: mt6359: add codec document

2020-08-16 Thread Jiaxin Yu
This patch adds MediaTek MT6359 codec document.

Signed-off-by: Jiaxin Yu 
---
 .../devicetree/bindings/sound/mt6359.yaml  | 68 ++
 1 file changed, 68 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/mt6359.yaml

diff --git a/Documentation/devicetree/bindings/sound/mt6359.yaml 
b/Documentation/devicetree/bindings/sound/mt6359.yaml
new file mode 100644
index 000..a669b49
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/mt6359.yaml
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/mt6359.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT6359 Codec Device Tree Bindings
+
+maintainers:
+  - Eason Yen 
+  - Jiaxin Yu 
+  - Shane Chien 
+
+description: |
+  The communication between MT6359 and SoC is through Mediatek PMIC wrapper.
+  For more detail, please visit Mediatek PMIC wrapper documentation.
+  Must be a child node of PMIC wrapper.
+
+properties:
+  compatible:
+const: mediatek,mt6359-sound
+
+  mediatek,dmic-mode:
+$ref: /schemas/types.yaml#/definitions/uint32
+description: |
+  Indicates how many data pins are used to transmit two channels of PDM
+  signal. 0 means two wires, 1 means one wire. Default value is 0.
+enum:
+  - 0 # one wire
+  - 1 # two wires
+
+  mediatek,mic-type-0:
+$ref: /schemas/types.yaml#/definitions/uint32
+description: |
+  Specifies the type of mic type connected to adc0
+
+enum:
+  - 0 # IDLE - mic in turn-off status
+  - 1 # ACC - analog mic with alternating coupling
+  - 2 # DMIC - digital mic
+  - 3 # DCC - analog mic with direct couping
+  - 4 # DCC_ECM_DIFF - analog electret condenser mic with differential mode
+  - 5 # DCC_ECM_SINGLE - analog electret condenser mic with single mode
+
+  mediatek,mic-type-1:
+$ref: /schemas/types.yaml#/definitions/uint32
+description: |
+  Specifies the type of mic type connected to adc1
+
+  mediatek,mic-type-2:
+$ref: /schemas/types.yaml#/definitions/uint32
+description: |
+  Specifies the type of mic type connected to adc2
+
+required:
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+mt6359codec: mt6359codec {
+  compatible = "mediatek,mt6359-sound";
+  mediatek,dmic-mode = <0>;
+  mediatek,mic-type-0 = <2>;
+};
+
+...
-- 
1.8.1.1.dirty


[PATCH v5 0/2] Add mediatek codec mt6359 driver

2020-08-16 Thread Jiaxin Yu
Add mediatek codec (MT6359) driver

MT6359 support playback and capture feature.

On downlink path, it includes three DACs for handset, headset,
and lineout path. On unlink path, it includeds three ADCs for
main mic, second mic, 3rd mic, and headset mic.

By scenario, select *_MUX widget to create damp path.
And by select mic_type_mux to choose DMIC/AMIC/

For example, select these MUX widget to create headset path
(1) DAC In Mux --> "Normal Path"
(2) HP Mux --> "Audio Playback"

v5 changes:
1. Don't need to unregister the component which is already relegated to 
devm.

v4 changes:
1. Add a remove() function to undo regulator_enable().
2. Removed unnecessary logs.
3. patchwork link:
https://patchwork.kernel.org/cover/11715553/
https://patchwork.kernel.org/patch/11716015/
https://patchwork.kernel.org/patch/11715557/
v3 changes:
1. patchwork link:
https://patchwork.kernel.org/cover/11714291/
https://patchwork.kernel.org/patch/11714295/
https://patchwork.kernel.org/patch/11714339/

v2 changes:
1. patchwork link:
https://patchwork.kernel.org/cover/11706935/
https://patchwork.kernel.org/patch/11708865/
https://patchwork.kernel.org/patch/11706937/

v1 changes:
1.lkml link:
https://lkml.org/lkml/2020/3/5/1257

Jiaxin Yu (2):
  ASoC: mediatek: mt6359: add codec driver
  dt-bindings: mediatek: mt6359: add codec document

 .../devicetree/bindings/sound/mt6359.yaml  |   68 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/mt6359.c  | 2753 
 sound/soc/codecs/mt6359.h  | 2640 +++
 5 files changed, 5471 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/mt6359.yaml
 create mode 100644 sound/soc/codecs/mt6359.c
 create mode 100644 sound/soc/codecs/mt6359.h

-- 
1.8.1.1.dirty


[PATCH] powerpc/fixmap: Fix the size of the early debug area

2020-08-16 Thread Christophe Leroy
Commit ("03fd42d458fb powerpc/fixmap: Fix FIX_EARLY_DEBUG_BASE when
page size is 256k") reworked the setup of the early debug area and
mistakenly replaced 128 * 1024 by SZ_128.

Change to SZ_128K to restore the original 128 kbytes size of the area.

Fixes: 03fd42d458fb ("powerpc/fixmap: Fix FIX_EARLY_DEBUG_BASE when page size 
is 256k")
Cc: sta...@vger.kernel.org
Signed-off-by: Christophe Leroy 
---
 arch/powerpc/include/asm/fixmap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/fixmap.h 
b/arch/powerpc/include/asm/fixmap.h
index 925cf89cbf4b..6bfc87915d5d 100644
--- a/arch/powerpc/include/asm/fixmap.h
+++ b/arch/powerpc/include/asm/fixmap.h
@@ -52,7 +52,7 @@ enum fixed_addresses {
FIX_HOLE,
/* reserve the top 128K for early debugging purposes */
FIX_EARLY_DEBUG_TOP = FIX_HOLE,
-   FIX_EARLY_DEBUG_BASE = FIX_EARLY_DEBUG_TOP+(ALIGN(SZ_128, 
PAGE_SIZE)/PAGE_SIZE)-1,
+   FIX_EARLY_DEBUG_BASE = FIX_EARLY_DEBUG_TOP+(ALIGN(SZ_128K, 
PAGE_SIZE)/PAGE_SIZE)-1,
 #ifdef CONFIG_HIGHMEM
FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
-- 
2.25.0



Re: [PATCH RFC 2/2] ARM: dts: imx: add devicetree for Tolino Shine 2 HD

2020-08-16 Thread Andreas Kemnade
Hi,

On Sun, 16 Aug 2020 17:57:51 +0200
Jonathan Neuschäfer  wrote:

> On Sun, Aug 16, 2020 at 04:50:58PM +0200, Andreas Kemnade wrote:
> > Hi,
> > 
> > Seems that we have different hardware, so the first question is
> > first the most interesting thing: how much does the hw actually differ,
> > especially do they require different device trees?
> > 
> > Can you provide me a photo of your hardware?
> > Or is it a Shine 3?  
> 
> It is a Shine 2HD
> 
> > 
> > Mine is at https://misc.andi.de1.cc/tolino2.jpg  
> 
> Mine:
> 
> https://raw.githubusercontent.com/wiki/neuschaefer/linux/Tolino-Shine2HD.jpg
> 
> 
> It appears to be the next PCB revision (+4A3 instead of +4A2), but I
> think the PCB layout looks the same. The Realtek-based Wifi module is
> exactly where the CyberTan WC121 was.
> 

From other sources I also think these revisions are same besides wifi.

So the only thing warranting separate dtbs might be the OOB IRQ thing.
In the Tolino sources there is the function dhd_customer_oob_irq_map in
the bcmdhd driver, and it gets its number from this:
drivers/net/wireless/bcmdhd/Makefile:   -DCUSTOMER_HW2 
-DCUSTOM_OOB_GPIO_NUM=127 -DOOB_INTR_ONLY -DHW_OOB

The brcmfmac driver is upstream and has devicetree support, but the
rtl8189fs is not. For the Clara I am using this one:
https://github.com/jwrdegoede/rtl8189ES_linux.git (branch 8189fs)
It has no devicetree support, so things cannot be defined anyway.

On one hand the hardware should be described in the devicetree as good
as possible but on the other hand the OOB IRQ is not mandatory.

Regards,
Andreas


[PATCH] KVM: x86: kvmclock_init_mem() should be called any way

2020-08-16 Thread Zelin Deng
pvclock data pointers of vCPUs >= HVC_BOOT_ARRAY_SIZE (64) are stored in
hvclock_mem wihch is initialized in kvmclock_init_mem().
Here're 3 scenarios in current implementation:
- no-kvmclock is set in cmdline. kvm pv clock driver is disabled,
  no impact.
- no-kvmclock-vsyscall is set in cmdline. kvmclock_init_mem() won't
  be called. No memory for storing pvclock data of vCPUs >= 64, vCPUs
  >= 64 can not be online or hotpluged.
- tsc unstable. kvmclock_init_mem() won't be called. vCPUs >= 64 can
  not be online or hotpluged.
It's not reasonable that vCPUs hotplug have been impacted by last 2
scenarios. Hence move kvmclock_init_mem() to front, in case hvclock_mem
can not be initialized unexpectedly.

Fixes: 6a1cac56f41f9 (x86/kvm: Use __bss_decrypted attribute in shared 
variables)
Signed-off-by: Zelin Deng 
---
 arch/x86/kernel/kvmclock.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index 34b18f6eeb2c..1abbda25e037 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -271,7 +271,14 @@ static int __init kvm_setup_vsyscall_timeinfo(void)
 {
 #ifdef CONFIG_X86_64
u8 flags;
+#endif
+
+   if (!kvmclock)
+   return 0;
+
+   kvmclock_init_mem();
 
+#ifdef CONFIG_X86_64
if (!per_cpu(hv_clock_per_cpu, 0) || !kvmclock_vsyscall)
return 0;
 
@@ -282,8 +289,6 @@ static int __init kvm_setup_vsyscall_timeinfo(void)
kvm_clock.vdso_clock_mode = VDSO_CLOCKMODE_PVCLOCK;
 #endif
 
-   kvmclock_init_mem();
-
return 0;
 }
 early_initcall(kvm_setup_vsyscall_timeinfo);
-- 
2.20.1



linux-next: Fixes tag needs some work in the net tree

2020-08-16 Thread Stephen Rothwell
Hi all,

In commit

  b3b2854dcf70 ("mptcp: sendmsg: reset iter on error redux")

Fixes tag

  Fixes: 35759383133f64d "(mptcp: sendmsg: reset iter on error)"

has these problem(s):

  - Subject does not match target commit subject
Just use
git log -1 --format='Fixes: %h ("%s")'

-- 
Cheers,
Stephen Rothwell


pgprI1Q1r6wmz.pgp
Description: OpenPGP digital signature


[PATCH v1 4/4] powerpc/process: Remove useless #ifdef CONFIG_PPC_FPU

2020-08-16 Thread Christophe Leroy
Add a stub for __giveup_fpu() when CONFIG_PPC_FPU is
not selected, as done for CONFIG_SPE and CONFIG_ALTIVEC.

This allows to remove some #ifdef CONFIG_PPC_FPU.

Also change one to IS_ENABLED().

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/process.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 7090c99a60d9..8133a6ce3242 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -229,6 +229,8 @@ void enable_kernel_fp(void)
}
 }
 EXPORT_SYMBOL(enable_kernel_fp);
+#else
+static inline void __giveup_fpu(struct task_struct *tsk) { }
 #endif /* CONFIG_PPC_FPU */
 
 #ifdef CONFIG_ALTIVEC
@@ -406,9 +408,8 @@ static unsigned long msr_all_available;
 
 static int __init init_msr_all_available(void)
 {
-#ifdef CONFIG_PPC_FPU
-   msr_all_available |= MSR_FP;
-#endif
+   if (IS_ENABLED(CONFIG_PPC_FPU))
+   msr_all_available |= MSR_FP;
if (cpu_has_feature(CPU_FTR_ALTIVEC))
msr_all_available |= MSR_VEC;
if (cpu_has_feature(CPU_FTR_VSX))
@@ -438,10 +439,8 @@ void giveup_all(struct task_struct *tsk)
 
WARN_ON((usermsr & MSR_VSX) && !((usermsr & MSR_FP) && (usermsr & 
MSR_VEC)));
 
-#ifdef CONFIG_PPC_FPU
if (usermsr & MSR_FP)
__giveup_fpu(tsk);
-#endif
if (usermsr & MSR_VEC)
__giveup_altivec(tsk);
if (usermsr & MSR_SPE)
-- 
2.25.0



[PATCH v1 2/4] powerpc/process: Remove useless #ifdef CONFIG_ALTIVEC

2020-08-16 Thread Christophe Leroy
cpu_has_feature(CPU_FTR_ALTIVEC) returns false when CONFIG_ALTIVEC is
not set.

There is no need to enclose the test in an #ifdef CONFIG_ALTIVEC.
Remove it.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/process.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index b64d71188715..360415689f8a 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -409,10 +409,8 @@ static int __init init_msr_all_available(void)
 #ifdef CONFIG_PPC_FPU
msr_all_available |= MSR_FP;
 #endif
-#ifdef CONFIG_ALTIVEC
if (cpu_has_feature(CPU_FTR_ALTIVEC))
msr_all_available |= MSR_VEC;
-#endif
if (cpu_has_feature(CPU_FTR_VSX))
msr_all_available |= MSR_VSX;
 #ifdef CONFIG_SPE
@@ -446,10 +444,8 @@ void giveup_all(struct task_struct *tsk)
if (usermsr & MSR_FP)
__giveup_fpu(tsk);
 #endif
-#ifdef CONFIG_ALTIVEC
if (usermsr & MSR_VEC)
__giveup_altivec(tsk);
-#endif
 #ifdef CONFIG_SPE
if (usermsr & MSR_SPE)
__giveup_spe(tsk);
-- 
2.25.0



[PATCH v1 1/4] powerpc/process: Remove useless #ifdef CONFIG_VSX

2020-08-16 Thread Christophe Leroy
cpu_has_feature(CPU_FTR_VSX) returns false when CONFIG_VSX is
not set.

There is no need to enclose the test in an #ifdef CONFIG_VSX.
Remove it.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/process.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index a17d0746d55f..b64d71188715 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -124,10 +124,8 @@ unsigned long notrace msr_check_and_set(unsigned long bits)
 
newmsr = oldmsr | bits;
 
-#ifdef CONFIG_VSX
if (cpu_has_feature(CPU_FTR_VSX) && (bits & MSR_FP))
newmsr |= MSR_VSX;
-#endif
 
if (oldmsr != newmsr)
mtmsr_isync(newmsr);
@@ -144,10 +142,8 @@ void notrace __msr_check_and_clear(unsigned long bits)
 
newmsr = oldmsr & ~bits;
 
-#ifdef CONFIG_VSX
if (cpu_has_feature(CPU_FTR_VSX) && (bits & MSR_FP))
newmsr &= ~MSR_VSX;
-#endif
 
if (oldmsr != newmsr)
mtmsr_isync(newmsr);
@@ -162,10 +158,8 @@ static void __giveup_fpu(struct task_struct *tsk)
save_fpu(tsk);
msr = tsk->thread.regs->msr;
msr &= ~(MSR_FP|MSR_FE0|MSR_FE1);
-#ifdef CONFIG_VSX
if (cpu_has_feature(CPU_FTR_VSX))
msr &= ~MSR_VSX;
-#endif
tsk->thread.regs->msr = msr;
 }
 
@@ -245,10 +239,8 @@ static void __giveup_altivec(struct task_struct *tsk)
save_altivec(tsk);
msr = tsk->thread.regs->msr;
msr &= ~MSR_VEC;
-#ifdef CONFIG_VSX
if (cpu_has_feature(CPU_FTR_VSX))
msr &= ~MSR_VSX;
-#endif
tsk->thread.regs->msr = msr;
 }
 
@@ -421,10 +413,8 @@ static int __init init_msr_all_available(void)
if (cpu_has_feature(CPU_FTR_ALTIVEC))
msr_all_available |= MSR_VEC;
 #endif
-#ifdef CONFIG_VSX
if (cpu_has_feature(CPU_FTR_VSX))
msr_all_available |= MSR_VSX;
-#endif
 #ifdef CONFIG_SPE
if (cpu_has_feature(CPU_FTR_SPE))
msr_all_available |= MSR_SPE;
@@ -509,19 +499,18 @@ static bool should_restore_altivec(void) { return false; }
 static void do_restore_altivec(void) { }
 #endif /* CONFIG_ALTIVEC */
 
-#ifdef CONFIG_VSX
 static bool should_restore_vsx(void)
 {
if (cpu_has_feature(CPU_FTR_VSX))
return true;
return false;
 }
+#ifdef CONFIG_VSX
 static void do_restore_vsx(void)
 {
current->thread.used_vsr = 1;
 }
 #else
-static bool should_restore_vsx(void) { return false; }
 static void do_restore_vsx(void) { }
 #endif /* CONFIG_VSX */
 
-- 
2.25.0



[PATCH v1 3/4] powerpc/process: Remove useless #ifdef CONFIG_SPE

2020-08-16 Thread Christophe Leroy
cpu_has_feature(CPU_FTR_SPE) returns false when CONFIG_SPE is
not set.

There is no need to enclose the test in an #ifdef CONFIG_SPE.
Remove it.

CPU_FTR_SPE only exists on 32 bits. Define it as 0 on 64 bits.

We have a couple of places like:

 #ifdef CONFIG_SPE
if (cpu_has_feature(CPU_FTR_SPE)) {
do_something_that_requires_CONFIG_SPE
} else {
return -EINVAL;
}
 #else
return -EINVAL;
 #endif

Replace them by a cleaner version:

if (cpu_has_feature(CPU_FTR_SPE)) {
 #ifdef CONFIG_SPE
do_something_that_requires_CONFIG_SPE
 #endif
} else {
return -EINVAL;
}

When CONFIG_SPE is not set, this resolves to an unconditional
return of -EINVAL

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/include/asm/cputable.h |  1 +
 arch/powerpc/kernel/process.c   | 21 +++--
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/include/asm/cputable.h 
b/arch/powerpc/include/asm/cputable.h
index fdddb822d564..cc21dbcc6794 100644
--- a/arch/powerpc/include/asm/cputable.h
+++ b/arch/powerpc/include/asm/cputable.h
@@ -165,6 +165,7 @@ static inline void cpu_feature_keys_init(void) { }
 #else  /* CONFIG_PPC32 */
 /* Define these to 0 for the sake of tests in common code */
 #define CPU_FTR_PPC_LE (0)
+#define CPU_FTR_SPE(0)
 #endif
 
 /*
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 360415689f8a..7090c99a60d9 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -413,10 +413,8 @@ static int __init init_msr_all_available(void)
msr_all_available |= MSR_VEC;
if (cpu_has_feature(CPU_FTR_VSX))
msr_all_available |= MSR_VSX;
-#ifdef CONFIG_SPE
if (cpu_has_feature(CPU_FTR_SPE))
msr_all_available |= MSR_SPE;
-#endif
 
return 0;
 }
@@ -446,10 +444,8 @@ void giveup_all(struct task_struct *tsk)
 #endif
if (usermsr & MSR_VEC)
__giveup_altivec(tsk);
-#ifdef CONFIG_SPE
if (usermsr & MSR_SPE)
__giveup_spe(tsk);
-#endif
 
msr_check_and_clear(msr_all_available);
 }
@@ -1843,7 +1839,6 @@ int set_fpexc_mode(struct task_struct *tsk, unsigned int 
val)
 * fpexc_mode.  fpexc_mode is also used for setting FP exception
 * mode (asyn, precise, disabled) for 'Classic' FP. */
if (val & PR_FP_EXC_SW_ENABLE) {
-#ifdef CONFIG_SPE
if (cpu_has_feature(CPU_FTR_SPE)) {
/*
 * When the sticky exception bits are set
@@ -1857,16 +1852,15 @@ int set_fpexc_mode(struct task_struct *tsk, unsigned 
int val)
 * anyway to restore the prctl settings from
 * the saved environment.
 */
+#ifdef CONFIG_SPE
tsk->thread.spefscr_last = mfspr(SPRN_SPEFSCR);
tsk->thread.fpexc_mode = val &
(PR_FP_EXC_SW_ENABLE | PR_FP_ALL_EXCEPT);
+#endif
return 0;
} else {
return -EINVAL;
}
-#else
-   return -EINVAL;
-#endif
}
 
/* on a CONFIG_SPE this does not hurt us.  The bits that
@@ -1887,8 +1881,7 @@ int get_fpexc_mode(struct task_struct *tsk, unsigned long 
adr)
 {
unsigned int val;
 
-   if (tsk->thread.fpexc_mode & PR_FP_EXC_SW_ENABLE)
-#ifdef CONFIG_SPE
+   if (tsk->thread.fpexc_mode & PR_FP_EXC_SW_ENABLE) {
if (cpu_has_feature(CPU_FTR_SPE)) {
/*
 * When the sticky exception bits are set
@@ -1902,15 +1895,15 @@ int get_fpexc_mode(struct task_struct *tsk, unsigned 
long adr)
 * anyway to restore the prctl settings from
 * the saved environment.
 */
+#ifdef CONFIG_SPE
tsk->thread.spefscr_last = mfspr(SPRN_SPEFSCR);
val = tsk->thread.fpexc_mode;
+#endif
} else
return -EINVAL;
-#else
-   return -EINVAL;
-#endif
-   else
+   } else {
val = __unpack_fe01(tsk->thread.fpexc_mode);
+   }
return put_user(val, (unsigned int __user *) adr);
 }
 
-- 
2.25.0



[PATCH v1] powerpc/process: Replace an #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) by IS_ENABLED()

2020-08-16 Thread Christophe Leroy
The #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) encloses some
printk which can be compiled in all cases.

Replace by IS_ENABLED().

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/process.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index fd3e11663613..087711aa0126 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1446,12 +1446,13 @@ void show_regs(struct pt_regs * regs)
trap = TRAP(regs);
if (!trap_is_syscall(regs) && cpu_has_feature(CPU_FTR_CFAR))
pr_cont("CFAR: "REG" ", regs->orig_gpr3);
-   if (trap == 0x200 || trap == 0x300 || trap == 0x600)
-#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
-   pr_cont("DEAR: "REG" ESR: "REG" ", regs->dar, regs->dsisr);
-#else
-   pr_cont("DAR: "REG" DSISR: %08lx ", regs->dar, regs->dsisr);
-#endif
+   if (trap == 0x200 || trap == 0x300 || trap == 0x600) {
+   if (IS_ENABLED(CONFIG_4xx) || IS_ENABLED(CONFIG_BOOKE))
+   pr_cont("DEAR: "REG" ESR: "REG" ", regs->dar, 
regs->dsisr);
+   else
+   pr_cont("DAR: "REG" DSISR: %08lx ", regs->dar, 
regs->dsisr);
+   }
+
 #ifdef CONFIG_PPC64
pr_cont("IRQMASK: %lx ", regs->softe);
 #endif
-- 
2.25.0



[PATCH v1] powerpc/process: Replace an #ifdef CONFIG_PPC_47x by IS_ENABLED()

2020-08-16 Thread Christophe Leroy
isync() is always defined, no need for an #ifdef.

Replace it by IS_ENABLED(CONFIG_PPC_47x).

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/process.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index e86e28c28259..fd3e11663613 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -777,9 +777,8 @@ static void switch_hw_breakpoint(struct task_struct *new)
 static inline int __set_dabr(unsigned long dabr, unsigned long dabrx)
 {
mtspr(SPRN_DAC1, dabr);
-#ifdef CONFIG_PPC_47x
-   isync();
-#endif
+   if (IS_ENABLED(CONFIG_PPC_47x))
+   isync();
return 0;
 }
 #elif defined(CONFIG_PPC_BOOK3S)
-- 
2.25.0



[PATCH v1] powerpc/process: Remove unnecessary #ifdef CONFIG_FUNCTION_GRAPH_TRACER

2020-08-16 Thread Christophe Leroy
ftrace_graph_ret_addr() is always defined and returns 'ip' when
CONFIG_FUNCTION GRAPH_TRACER is not set.

So the #ifdef is not needed, remove it.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/process.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index ffbe79960c73..e86e28c28259 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -2096,10 +2096,8 @@ void show_stack(struct task_struct *tsk, unsigned long 
*stack,
unsigned long sp, ip, lr, newsp;
int count = 0;
int firstframe = 1;
-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
unsigned long ret_addr;
int ftrace_idx = 0;
-#endif
 
if (tsk == NULL)
tsk = current;
@@ -2127,12 +2125,10 @@ void show_stack(struct task_struct *tsk, unsigned long 
*stack,
if (!firstframe || ip != lr) {
printk("%s["REG"] ["REG"] %pS",
loglvl, sp, ip, (void *)ip);
-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
ret_addr = ftrace_graph_ret_addr(current,
&ftrace_idx, ip, stack);
if (ret_addr != ip)
pr_cont(" (%pS)", (void *)ret_addr);
-#endif
if (firstframe)
pr_cont(" (unreliable)");
pr_cont("\n");
-- 
2.25.0



[PATCH v1] powerpc/process: Replace an #ifdef CONFIG_PPC_BOOK3S_64 by IS_ENABLED()

2020-08-16 Thread Christophe Leroy
This #ifdef CONFIG_PPC_BOOK3S_64 calls preload_new_slb_context()
when radix is not enabled.

radix_enabled() is always defined, and the prototype for
preload_new_slb_context() is always present, so the #ifdef
is unneeded.

Replace it by IS_ENABLED().

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/process.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 987bc8e73d5e..a17d0746d55f 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1725,10 +1725,8 @@ void start_thread(struct pt_regs *regs, unsigned long 
start, unsigned long sp)
 #ifdef CONFIG_PPC64
unsigned long load_addr = regs->gpr[2]; /* saved by ELF_PLAT_INIT */
 
-#ifdef CONFIG_PPC_BOOK3S_64
-   if (!radix_enabled())
+   if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && !radix_enabled())
preload_new_slb_context(start, sp);
-#endif
 #endif
 
/*
-- 
2.25.0



[PATCH v1] powerpc/process: Tag an #endif to help locate the matching #ifdef.

2020-08-16 Thread Christophe Leroy
That #endif is more than 100 lines after the matching #ifdef,
and there are several #ifdef/#else/#endif inbetween.

Tag it as /* CONFIG_PPC_BOOK3S_64 */ to help locate the
matching #ifdef.

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

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 016bd831908e..ffbe79960c73 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -575,7 +575,7 @@ void notrace restore_math(struct pt_regs *regs)
regs->msr |= new_msr;
}
 }
-#endif
+#endif /* CONFIG_PPC_BOOK3S_64 */
 
 static void save_all(struct task_struct *tsk)
 {
-- 
2.25.0



[PATCH v1] powerpc/process: Replace #ifdef CONFIG_KALLSYMS by IS_ENABLED()

2020-08-16 Thread Christophe Leroy
The #ifdef CONFIG_KALLSYMS encloses some printk which can
compile in all cases.

Replace by IS_ENABLED().

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/process.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 087711aa0126..987bc8e73d5e 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1469,14 +1469,14 @@ void show_regs(struct pt_regs * regs)
break;
}
pr_cont("\n");
-#ifdef CONFIG_KALLSYMS
/*
 * Lookup NIP late so we have the best change of getting the
 * above info out without failing
 */
-   printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
-   printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
-#endif
+   if (IS_ENABLED(CONFIG_KALLSYMS)) {
+   printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
+   printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
+   }
show_stack(current, (unsigned long *) regs->gpr[1], KERN_DEFAULT);
if (!user_mode(regs))
show_instructions(regs);
-- 
2.25.0



Re: pcm|dmaengine|imx-sdma race condition on i.MX6

2020-08-16 Thread Richard Leitner
On Fri, Aug 14, 2020 at 11:18:10AM +0200, Robin Gong wrote:
> 
> On 2020/08/13 19:23: Richard Leitner  wrote:
> > Hi,
> > we've found a race condition with the PCM on the i.MX6 which results 
> > in an -EIO for the SNDRV_PCM_IOCTL_READI_FRAMES ioctl after an -EPIPE 
> > (XRUN).
> > 
> > A possible reproduction may look like the following reduced call graph 
> > during a PCM capture:
> > 
> > us -> ioctl(SNDRV_PCM_IOCTL_READI_FRAMES)
> >   - wait_for_avail()
> > - schedule_timeout()
> >-> snd_pcm_update_hw_ptr0()
> >   - snd_pcm_update_state: EPIPE (XRUN)
> >   - sdma_disable_channel_async() # get's scheduled away due to sleep us
> > <- ioctl(SNDRV_PCM_IOCTL_READI_FRAMES) returns -EPIPE
> > us -> ioctl(SNDRV_PCM_IOCTL_PREPARE) # as reaction to the EPIPE (XRUN)
> > us -> ioctl(SNDRV_PCM_IOCTL_READI_FRAMES) # next try to capture frames
> >   - sdma_prep_dma_cyclic()
> > - sdma_load_context() # not loaded as context_loaded is 1
> >   - wait_for_avail()
> > - schedule_timeout()
> > # now the sdma_channel_terminate_work() comes back and sets # 
> > context_loaded = false and frees in vchan_dma_desc_free_list().
> > us <- ioctl returns -EIO (capture write error (DMA or IRQ trouble?))
>
> Seems the write error caused by context_loaded not set to false before
> next transfer start? If yes, please have a try with the 03/04 of the below
> patch set, anyway, could you post your failure log?
> https://lkml.org/lkml/2020/8/11/111

Thanks for the pointer to those patches. I've tested them on top of the
v5.8 tag during the weekend. It seems those patches are mitigiating
the described EIO issue.

Nonetheless IMHO this patches are not fixing the root cause of the
problem (unsynchronized sdma_disable_channel_async / sdma_prep_dma_cyclic).
Do you (or somebody else) have any suggestions/comments/objections on that?

regards;rl

> 
> > 
> > 
> > What we have found out, based on our understanding:
> > The dmaengine docu states that a dmaengine_terminate_async() must be 
> > followed by a dmaengine_synchronize().
> > However, in the pcm_dmaengine.c, only dmaengine_terminate_async() is 
> > called (for performance reasons and because it might be called from an 
> > interrupt handler).
> > 
> > In our tests, we saw that the user-space immediately calls
> > ioctl(SNDRV_PCM_IOCTL_PREPARE) as a handler for the happened xrun 
> > (previous ioctl(SNDRV_PCM_IOCTL_READI_FRAMES) returns with -EPIPE). In 
> > our case (imx-sdma.c), the terminate really happens asynchronously 
> > with a worker thread which is not awaited/synchronized by the
> > ioctl(SNDRV_PCM_IOCTL_PREPARE) call.
> > 
> > Since the syscall immediately enters an atomic context 
> > (snd_pcm_stream_lock_irq()), we are not able to flush the work of the 
> > termination worker from within the DMA context. This leads to an 
> > unterminated DMA getting re-initialized and then terminated.
> > 
> > On the i.MX6 platform the problem is (if I got it correctly) that the
> > sdma_channel_terminate_work() called after the -EPIPE gets scheduled 
> > away (for the 1-2ms sleep [1]). During that time the userspace already 
> > sends in the
> > ioctl(SNDRV_PCM_IOCTL_PREPARE) and
> > ioctl(SNDRV_PCM_IOCTL_READI_FRAMES).
> > As none of them are anyhow synchronized to the terminate_worker the
> > vchan_dma_desc_free_list() [2] and "sdmac->context_loaded = false;" 
> > [3] are executed during the wait_for_avail() [4] of the 
> > ioctl(SNDRV_PCM_IOCTL_READI_FRAMES).
> > 
> > To make sure we identified the problem correctly we've tested to add a 
> > "dmaengine_synchronize()" before the snd_pcm_prepare() in [5]. This 
> > fixed the race condition in all our tests. (Before we were able to 
> > reproduce it in 100% of the test runs).
> > 
> > Based on our understanding, there are two different points to ensure 
> > the
> > termination:
> > Either ensure that the termination is finished within the previous 
> > SNDRV_PCM_IOCTL_READI_FRAMES call (inside the DMA context) or 
> > finishing it in the SNDRV_PCM_IOCTL_PREPARE call (and all other 
> > applicable ioclts) before entering the atomic context (from the PCM 
> > context).
> > 
> > We initially thought about implementing the first approach, basically 
> > splitting up the dma_device terminate_all operation into a sync
> > (busy-wait) and a async one. This would align the operations with the 
> > DMAengine interface and would enable a sync termination variant from 
> > atomic contexts.
> > However, we saw that the dma_free_attrs() function has a WARN_ON on 
> > irqs disabled, which would be the case for the sync variant.
> > Side note: We found this issue on the current v5.4.y LTS branch, but 
> > it also affects v5.8.y.
> > 
> > Any feedback or pointers how we may fix the problem are warmly welcome!
> > If anything is unclear please just ask :-)
> > 
> > regards;
> > Richard Leitner
> > Benjamin Bara


Re: [PATCH v12 04/12] dmaengine: imx-sdma: remove duplicated sdma_load_context

2020-08-16 Thread Richard Leitner
On Tue, Aug 11, 2020 at 11:53:43PM +0800, Robin Gong wrote:
> Since sdma_transfer_init() will do sdma_load_context before any
> sdma transfer, no need once more in sdma_config_channel().
> 
> Signed-off-by: Robin Gong 
> Acked-by: Vinod Koul 

Hi Robin,
thanks for the pointer to this patch.

As you suggested I've tested the two patches on my custom i.MX6DL
board. Therefore please feel free to add:

Tested-by: Richard Leitner 

regards;rl

> ---
>  drivers/dma/imx-sdma.c | 5 +
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
> index d305b80..5411e01e 100644
> --- a/drivers/dma/imx-sdma.c
> +++ b/drivers/dma/imx-sdma.c
> @@ -1137,7 +1137,6 @@ static void sdma_set_watermarklevel_for_p2p(struct 
> sdma_channel *sdmac)
>  static int sdma_config_channel(struct dma_chan *chan)
>  {
>   struct sdma_channel *sdmac = to_sdma_chan(chan);
> - int ret;
>  
>   sdma_disable_channel(chan);
>  
> @@ -1177,9 +1176,7 @@ static int sdma_config_channel(struct dma_chan *chan)
>   sdmac->watermark_level = 0; /* FIXME: M3_BASE_ADDRESS */
>   }
>  
> - ret = sdma_load_context(sdmac);
> -
> - return ret;
> + return 0;
>  }
>  
>  static int sdma_set_channel_priority(struct sdma_channel *sdmac,
> -- 
> 2.7.4
> 
> 

-- 
Richard Leitner
Hardware R&D / Senior Embedded Linux Engineer

SKIDATA | Driving Your Digital Future

SKIDATA GmbH
Untersbergstraße 40 | 5083 Grödig/Salzburg | Austria
[t] +43-6246-888-4245 | [m] +43-664-88616370
[w] www.skidata.com


Re: [PATCH v12 03/12] Revert "dmaengine: imx-sdma: refine to load context only once"

2020-08-16 Thread Richard Leitner
On Tue, Aug 11, 2020 at 11:53:42PM +0800, Robin Gong wrote:
> This reverts commit ad0d92d7ba6aecbe2705907c38ff8d8be4da1e9c, because
> in spi-imx case, burst length may be changed dynamically.
> 
> Signed-off-by: Robin Gong 
> Acked-by: Sascha Hauer 

Hi Robin,
thanks for the pointer to this patch.

As you suggested I've tested the two patches on my custom i.MX6DL
board. Therefore please feel free to add:

Tested-by: Richard Leitner 

regards;rl

> ---
>  drivers/dma/imx-sdma.c | 8 
>  1 file changed, 8 deletions(-)
> 
> diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
> index 270992c..d305b80 100644
> --- a/drivers/dma/imx-sdma.c
> +++ b/drivers/dma/imx-sdma.c
> @@ -377,7 +377,6 @@ struct sdma_channel {
>   unsigned long   watermark_level;
>   u32 shp_addr, per_addr;
>   enum dma_status status;
> - boolcontext_loaded;
>   struct imx_dma_data data;
>   struct work_struct  terminate_worker;
>  };
> @@ -984,9 +983,6 @@ static int sdma_load_context(struct sdma_channel *sdmac)
>   int ret;
>   unsigned long flags;
>  
> - if (sdmac->context_loaded)
> - return 0;
> -
>   if (sdmac->direction == DMA_DEV_TO_MEM)
>   load_address = sdmac->pc_from_device;
>   else if (sdmac->direction == DMA_DEV_TO_DEV)
> @@ -1029,8 +1025,6 @@ static int sdma_load_context(struct sdma_channel *sdmac)
>  
>   spin_unlock_irqrestore(&sdma->channel_0_lock, flags);
>  
> - sdmac->context_loaded = true;
> -
>   return ret;
>  }
>  
> @@ -1069,7 +1063,6 @@ static void sdma_channel_terminate_work(struct 
> work_struct *work)
>   vchan_get_all_descriptors(&sdmac->vc, &head);
>   spin_unlock_irqrestore(&sdmac->vc.lock, flags);
>   vchan_dma_desc_free_list(&sdmac->vc, &head);
> - sdmac->context_loaded = false;
>  }
>  
>  static int sdma_terminate_all(struct dma_chan *chan)
> @@ -1337,7 +1330,6 @@ static void sdma_free_chan_resources(struct dma_chan 
> *chan)
>  
>   sdmac->event_id0 = 0;
>   sdmac->event_id1 = 0;
> - sdmac->context_loaded = false;
>  
>   sdma_set_channel_priority(sdmac, 0);
>  
> -- 
> 2.7.4
> 
> 

-- 
Richard Leitner
Hardware R&D / Senior Embedded Linux Engineer

SKIDATA | Driving Your Digital Future

SKIDATA GmbH
Untersbergstraße 40 | 5083 Grödig/Salzburg | Austria
[t] +43-6246-888-4245 | [m] +43-664-88616370
[w] www.skidata.com


Re: [PATCH v5 1/3] net: introduce helper sendpage_ok() in include/linux/net.h

2020-08-16 Thread Christoph Hellwig
On Sun, Aug 16, 2020 at 10:55:09AM -0700, Cong Wang wrote:
> On Sun, Aug 16, 2020 at 1:36 AM Coly Li  wrote:
> >
> > The original problem was from nvme-over-tcp code, who mistakenly uses
> > kernel_sendpage() to send pages allocated by __get_free_pages() without
> > __GFP_COMP flag. Such pages don't have refcount (page_count is 0) on
> > tail pages, sending them by kernel_sendpage() may trigger a kernel panic
> > from a corrupted kernel heap, because these pages are incorrectly freed
> > in network stack as page_count 0 pages.
> >
> > This patch introduces a helper sendpage_ok(), it returns true if the
> > checking page,
> > - is not slab page: PageSlab(page) is false.
> > - has page refcount: page_count(page) is not zero
> >
> > All drivers who want to send page to remote end by kernel_sendpage()
> > may use this helper to check whether the page is OK. If the helper does
> > not return true, the driver should try other non sendpage method (e.g.
> > sock_no_sendpage()) to handle the page.
> 
> Can we leave this helper to mm subsystem?
> 
> I know it is for sendpage, but its implementation is all about some
> mm details and its two callers do not belong to net subsystem either.
> 
> Think this in another way: who would fix it if it is buggy? I bet mm people
> should. ;)

No.  This is all about a really unusual imitation in sendpage, which
is pretty much unexpected.  In fact the best thing would be to make
sock_sendpage do the right thing and call sock_no_sendpage based
on this condition, so that driver writers don't have to worry at all.


Re: [RFC V2 1/2] arm64/mm: Change THP helpers per generic memory semantics

2020-08-16 Thread Anshuman Khandual



On 07/07/2020 11:14 PM, Catalin Marinas wrote:
> On Mon, Jul 06, 2020 at 09:27:04AM +0530, Anshuman Khandual wrote:
>> On 07/02/2020 05:41 PM, Catalin Marinas wrote:
>>> On Mon, Jun 15, 2020 at 06:45:17PM +0530, Anshuman Khandual wrote:
 --- a/arch/arm64/include/asm/pgtable.h
 +++ b/arch/arm64/include/asm/pgtable.h
 @@ -353,15 +353,92 @@ static inline int pmd_protnone(pmd_t pmd)
  }
  #endif
  
 +#define pmd_table(pmd)((pmd_val(pmd) & PMD_TYPE_MASK) ==  
 PMD_TYPE_TABLE)
 +#define pmd_sect(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) ==  
 PMD_TYPE_SECT)
 +
 +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
  /*
 - * THP definitions.
 + * PMD Level Encoding (THP Enabled)
 + *
 + * 0b00 - Not valid   Not present NA
 + * 0b10 - Not valid   Present Huge  (Splitting)
 + * 0b01 - Valid   Present Huge  (Mapped)
 + * 0b11 - Valid   Present Table (Mapped)
   */
>>>
>>> I wonder whether it would be easier to read if we add a dedicated
>>> PMD_SPLITTING bit, only when bit 0 is cleared. This bit can be high (say
>>> 59), it doesn't really matter as the entry is not valid.
>>
>> Could make (PMD[0b00] = 0b10) be represented as PMD_SPLITTING just for
>> better reading purpose. But if possible, IMHO it is efficient and less
>> vulnerable to use HW defined PTE attribute bit positions including SW
>> usable ones than the reserved bits, for a PMD state representation.
>>
>> Earlier proposal used PTE_SPECIAL (bit 56) instead. Using PMD_TABLE_BIT
>> helps save bit 56 for later. Thinking about it again, would not these
>> unused higher bits [59..63] create any problem ? For example while
>> enabling THP swapping without split via ARCH_WANTS_THP_SWAP or something
>> else later when these higher bits might be required. I am not sure, just
>> speculating.
> 
> The swap encoding goes to bit 57, so going higher shouldn't be an issue.
> 
>> But, do you see any particular problem with PMD_TABLE_BIT ?
> 
> No. Only that we have some precedent like PTE_PROT_NONE (bit 58) and
> wondering whether we could use a high bit as well here. If we can get
> them to overlap, it simplifies this patch further.
> 
>>> The only doubt I have is that pmd_mkinvalid() is used in other contexts
>>> when it's not necessarily splitting a pmd (search for the
>>> pmdp_invalidate() calls). So maybe a better name like PMD_PRESENT with a
>>> comment that pmd_to_page() is valid (i.e. no migration or swap entry).
>>> Feel free to suggest a better name.
>>
>> PMD_INVALID_PRESENT sounds better ?
> 
> No strong opinion either way. Yours is clearer.
> 
 +static inline pmd_t pmd_mksplitting(pmd_t pmd)
 +{
 +  unsigned long val = pmd_val(pmd);
  
 -#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 -#define pmd_trans_huge(pmd)   (pmd_val(pmd) && !(pmd_val(pmd) & 
 PMD_TABLE_BIT))
 +  return __pmd((val & ~PMD_TYPE_MASK) | PMD_TABLE_BIT);
 +}
 +
 +static inline pmd_t pmd_clrsplitting(pmd_t pmd)
 +{
 +  unsigned long val = pmd_val(pmd);
 +
 +  return __pmd((val & ~PMD_TYPE_MASK) | PMD_TYPE_SECT);
 +}
 +
 +static inline bool pmd_splitting(pmd_t pmd)
 +{
 +  unsigned long val = pmd_val(pmd);
 +
 +  if ((val & PMD_TYPE_MASK) == PMD_TABLE_BIT)
 +  return true;
 +  return false;
 +}
 +
 +static inline bool pmd_mapped(pmd_t pmd)
 +{
 +  return pmd_sect(pmd);
 +}
 +
 +static inline pmd_t pmd_mkinvalid(pmd_t pmd)
 +{
 +  /*
 +   * Invalidation should not have been invoked on
 +   * a PMD table entry. Just warn here otherwise.
 +   */
 +  WARN_ON(pmd_table(pmd));
 +  return pmd_mksplitting(pmd);
 +}
>>>
>>> And here we wouldn't need t worry about table checks.
>>
>> This is just a temporary sanity check validating the assumption
>> that a table entry would never be called with pmdp_invalidate().
>> This can be dropped later on if required.
> 
> You could use a VM_WARN_ON.
> 
 +static inline int pmd_present(pmd_t pmd);
 +
 +static inline int pmd_trans_huge(pmd_t pmd)
 +{
 +  if (!pmd_present(pmd))
 +  return 0;
 +
 +  if (!pmd_val(pmd))
 +  return 0;
 +
 +  if (pmd_mapped(pmd))
 +  return 1;
 +
 +  if (pmd_splitting(pmd))
 +  return 1;
 +  return 0;
>>>
>>> Doesn't your new pmd_present() already check for splitting? I think
>>
>> I actually meant pte_present() here instead, my bad.
>>
>>> checking for bit 0 and the new PMD_PRESENT. That would be similar to
>>> what we do with PTE_PROT_NONE. Actually, you could use the same bit for
>>> both.
>>
>> IIUC PROT NONE is supported at PMD level as well. Hence with valid bit
>> cleared, there is a chance for misinterpretation between pmd_protnone()
>> and pmd_splitting() if the same bit (PTE_PROT_NONE) is used.
> 
> We can indeed have a PROT_NONE pmd but does it matter? 

Re: [PATCH] dmaengine: of-dma: Fix of_dma_router_xlate's of_dma_xlate handling

2020-08-16 Thread Vinod Koul
On 06-08-20, 13:49, Peter Ujfalusi wrote:
> of_dma_xlate callback can return ERR_PTR as well NULL in case of failure.
> 
> If error code is returned (not NULL) then the route should be released and
> the router should not be registered for the channel.

Applied, thanks

-- 
~Vinod


Re: [PATCH] phylink: : fix function prototype kernel-doc warning

2020-08-16 Thread Randy Dunlap
On 8/16/20 9:14 PM, David Miller wrote:
> From: Randy Dunlap 
> Date: Sun, 16 Aug 2020 15:25:49 -0700
> 
>> Fix a kernel-doc warning for the pcs_config() function prototype:
>>
>> ../include/linux/phylink.h:406: warning: Excess function parameter 
>> 'permit_pause_to_mac' description in 'pcs_config'
>>
>> Fixes: 7137e18f6f88 ("net: phylink: add struct phylink_pcs")
>> Signed-off-by: Randy Dunlap 
> 
> There's no definition of this function anywhere.  Maybe just remove all of
> this?
> 

It's for documentation purposes...

It's a "method" (callback) function.

-- 
~Randy



Re: [PATCH] uprobes: __replace_page() avoid BUG in munlock_vma_page()

2020-08-16 Thread Song Liu



> On Aug 16, 2020, at 1:44 PM, Hugh Dickins  wrote:
> 
> syzbot crashed on the VM_BUG_ON_PAGE(PageTail) in munlock_vma_page(),
> when called from uprobes __replace_page().  Which of many ways to fix it?
> Settled on not calling when PageCompound (since Head and Tail are equals
> in this context, PageCompound the usual check in uprobes.c, and the prior
> use of FOLL_SPLIT_PMD will have cleared PageMlocked already).
> 
> Reported-by: syzbot 
> Fixes: 5a52c9df62b4 ("uprobe: use FOLL_SPLIT_PMD instead of FOLL_SPLIT")
> Signed-off-by: Hugh Dickins 
> Cc: sta...@vger.kernel.org # v5.4+
> ---
> This one is not a 5.9-rc regression, but still good to fix.
> 
> kernel/events/uprobes.c |2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- v5.9-rc/kernel/events/uprobes.c   2020-08-12 19:46:50.851196584 -0700
> +++ linux/kernel/events/uprobes.c 2020-08-16 13:18:35.292821674 -0700
> @@ -205,7 +205,7 @@ static int __replace_page(struct vm_area
>   try_to_free_swap(old_page);
>   page_vma_mapped_walk_done(&pvmw);
> 
> - if (vma->vm_flags & VM_LOCKED)
> + if ((vma->vm_flags & VM_LOCKED) && !PageCompound(old_page))

Do we need munlock_vma_page() for THP page head? 

Thanks,
Song

>   munlock_vma_page(old_page);
>   put_page(old_page);
> 



RE: [PATCH v6 09/15] iommu/vt-d: Check ownership for PASIDs from user-space

2020-08-16 Thread Liu, Yi L
Hi Eric,

> From: Auger Eric 
> Sent: Sunday, August 16, 2020 12:30 AM
> 
> Hi Yi,
> 
> On 7/28/20 8:27 AM, Liu Yi L wrote:
> > When an IOMMU domain with nesting attribute is used for guest SVA, a
> > system-wide PASID is allocated for binding with the device and the domain.
> > For security reason, we need to check the PASID passed from user-space.
> > e.g. page table bind/unbind and PASID related cache invalidation.
> >
> > Cc: Kevin Tian 
> > CC: Jacob Pan 
> > Cc: Alex Williamson 
> > Cc: Eric Auger 
> > Cc: Jean-Philippe Brucker 
> > Cc: Joerg Roedel 
> > Cc: Lu Baolu 
> > Signed-off-by: Liu Yi L 
> > Signed-off-by: Jacob Pan 
> > ---
> >  drivers/iommu/intel/iommu.c | 10 ++
> >  drivers/iommu/intel/svm.c   |  7 +--
> >  2 files changed, 15 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> > index b2fe54e..88f4647 100644
> > --- a/drivers/iommu/intel/iommu.c
> > +++ b/drivers/iommu/intel/iommu.c
> > @@ -5436,6 +5436,7 @@ intel_iommu_sva_invalidate(struct iommu_domain
> *domain, struct device *dev,
> > int granu = 0;
> > u64 pasid = 0;
> > u64 addr = 0;
> > +   void *pdata;
> >
> > granu = to_vtd_granularity(cache_type, inv_info->granularity);
> > if (granu == -EINVAL) {
> > @@ -5456,6 +5457,15 @@ intel_iommu_sva_invalidate(struct iommu_domain
> *domain, struct device *dev,
> >  (inv_info->granu.addr_info.flags &
> IOMMU_INV_ADDR_FLAGS_PASID))
> > pasid = inv_info->granu.addr_info.pasid;
> >
> > +   pdata = ioasid_find(dmar_domain->ioasid_sid, pasid, NULL);
> > +   if (!pdata) {
> > +   ret = -EINVAL;
> > +   goto out_unlock;
> > +   } else if (IS_ERR(pdata)) {
> > +   ret = PTR_ERR(pdata);
> > +   goto out_unlock;
> > +   }
> > +
> > switch (BIT(cache_type)) {
> > case IOMMU_CACHE_INV_TYPE_IOTLB:
> > /* HW will ignore LSB bits based on address mask */
> > diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
> > index c85b8d5..b9b29ad 100644
> > --- a/drivers/iommu/intel/svm.c
> > +++ b/drivers/iommu/intel/svm.c
> > @@ -323,7 +323,7 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain,
> struct device *dev,
> > dmar_domain = to_dmar_domain(domain);
> >
> > mutex_lock(&pasid_mutex);
> > -   svm = ioasid_find(INVALID_IOASID_SET, data->hpasid, NULL);
> > +   svm = ioasid_find(dmar_domain->ioasid_sid, data->hpasid, NULL);
> A question about the locking strategy. We don't take the
> device_domain_lock here. Could you clarify whether it is safe?

I guess it is better to take the same lock as what iommu_domain_set_attr()
takes. thanks for catching it. :-)

> 
> > if (IS_ERR(svm)) {
> > ret = PTR_ERR(svm);
> > goto out;
> > @@ -440,6 +440,7 @@ int intel_svm_unbind_gpasid(struct iommu_domain
> *domain,
> > struct device *dev, u32 pasid)
> >  {
> > struct intel_iommu *iommu = intel_svm_device_to_iommu(dev);
> > +   struct dmar_domain *dmar_domain;
> > struct intel_svm_dev *sdev;
> > struct intel_svm *svm;
> > int ret = -EINVAL;
> > @@ -447,8 +448,10 @@ int intel_svm_unbind_gpasid(struct iommu_domain
> *domain,
> > if (WARN_ON(!iommu))
> > return -EINVAL;
> >
> > +   dmar_domain = to_dmar_domain(domain);
> > +
> > mutex_lock(&pasid_mutex);
> > -   svm = ioasid_find(INVALID_IOASID_SET, pasid, NULL);
> > +   svm = ioasid_find(dmar_domain->ioasid_sid, pasid, NULL);
> same here.

same.

Regards,
Yi Liu

> > if (!svm) {
> > ret = -EINVAL;
> > goto out;
> >
> Thanks
> 
> Eric



Re: [PATCH V3 0/3] x86/entry: simply stack switching when exception on userspace

2020-08-16 Thread Lai Jiangshan



Deeply sorry, the cover-letter was forgotten to send to LKML.

Here it is:

On 2020/8/17 14:23, Lai Jiangshan wrote:

From: Lai Jiangshan 

7f2590a110b8("x86/entry/64: Use a per-CPU trampoline stack for IDT entries")
has resulted that when exception on userspace, the kernel (error_entry)
always push the pt_regs to entry stack(sp0), and then copy them to the
kernel stack.

And recent x86/entry work makes interrupt also use idtentry
and makes all the interrupt code save the pt_regs on the sp0 stack
and then copy it to the thread stack like exception.

This is hot path (page fault, ipi), such overhead should be avoided.
And the original interrupt_entry directly switches to kernel stack
and pushes pt_regs to kernel stack. We should do it for error_entry.
This is the job of patch1.

Patch 2-3 simplify stack switching for .Lerror_bad_iret by just doing
all the work in one function (fixup_bad_iret()).

The patch set is based on v5.9-rc1

Changed from V1:
based on tip/master -> based on tip/x86/entry

patch 1 replaces the patch1,2 of V1, it borrows the
original interrupt_entry's code into error_entry.

patch2-4 is V1's patch3-5, unchanged (but rebased)

Changed from V2:
(re-)based on v5.9-rc1
drop the patch4 of V2 patchset

Cc: Andy Lutomirski ,
Cc: Thomas Gleixner ,
Cc: Ingo Molnar ,
Cc: Borislav Petkov ,
Cc: x...@kernel.org,
Cc: "H. Peter Anvin" ,
Cc: Peter Zijlstra ,
Cc: Alexandre Chartre ,
Cc: "Eric W. Biederman" ,
Cc: Jann Horn ,
Cc: Dave Hansen 


Lai Jiangshan (3):
   x86/entry: avoid calling into sync_regs() when entering from userspace
   x86/entry: directly switch to kernel stack when .Lerror_bad_iret
   x86/entry: remove unused sync_regs()

  arch/x86/entry/entry_64.S| 52 +++-
  arch/x86/include/asm/traps.h |  1 -
  arch/x86/kernel/traps.c  | 22 +++
  3 files changed, 38 insertions(+), 37 deletions(-)



[PATCH V2] arm64: dts: ipq8074: Use the A53 PMU compatible

2020-08-16 Thread Kathiravan T
IPQ8074 has A53 cores, so lets use the corresponding PMU compatible.

Signed-off-by: Kathiravan T 
---
[V2]
- Rebased on v5.9-rc1

 arch/arm64/boot/dts/qcom/ipq8074.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/ipq8074.dtsi 
b/arch/arm64/boot/dts/qcom/ipq8074.dtsi
index 96a5ec89b5f0..e4859c7f6208 100644
--- a/arch/arm64/boot/dts/qcom/ipq8074.dtsi
+++ b/arch/arm64/boot/dts/qcom/ipq8074.dtsi
@@ -67,7 +67,7 @@
};
 
pmu {
-   compatible = "arm,armv8-pmuv3";
+   compatible = "arm,cortex-a53-pmu";
interrupts = ;
};
 
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation



RE: [PATCH v6 07/15] vfio/type1: Add VFIO_IOMMU_PASID_REQUEST (alloc/free)

2020-08-16 Thread Liu, Yi L
Thanks, Eric.

Regards,
Yi Liu

> From: Auger Eric 
> Sent: Sunday, August 16, 2020 12:30 AM
> 
> Yi,
> 
> On 7/28/20 8:27 AM, Liu Yi L wrote:
> > This patch allows userspace to request PASID allocation/free, e.g.
> > when serving the request from the guest.
> >
> > PASIDs that are not freed by userspace are automatically freed when
> > the IOASID set is destroyed when process exits.
> >
> > Cc: Kevin Tian 
> > CC: Jacob Pan 
> > Cc: Alex Williamson 
> > Cc: Eric Auger 
> > Cc: Jean-Philippe Brucker 
> > Cc: Joerg Roedel 
> > Cc: Lu Baolu 
> > Signed-off-by: Liu Yi L 
> > Signed-off-by: Yi Sun 
> > Signed-off-by: Jacob Pan 
> > ---
> > v5 -> v6:
> > *) address comments from Eric against v5. remove the alloc/free helper.
> >
> > v4 -> v5:
> > *) address comments from Eric Auger.
> > *) the comments for the PASID_FREE request is addressed in patch 5/15 of
> >this series.
> >
> > v3 -> v4:
> > *) address comments from v3, except the below comment against the range
> >of PASID_FREE request. needs more help on it.
> > "> +if (req.range.min > req.range.max)
> >
> >  Is it exploitable that a user can spin the kernel for a long time in
> >  the case of a free by calling this with [0, MAX_UINT] regardless of
> >  their actual allocations?"
> >
> > https://lore.kernel.org/linux-iommu/20200702151832.048b4...@x1.home/
> >
> > v1 -> v2:
> > *) move the vfio_mm related code to be a seprate module
> > *) use a single structure for alloc/free, could support a range of
> > PASIDs
> > *) fetch vfio_mm at group_attach time instead of at iommu driver open
> > time
> > ---
> >  drivers/vfio/Kconfig|  1 +
> >  drivers/vfio/vfio_iommu_type1.c | 69
> +
> >  drivers/vfio/vfio_pasid.c   | 10 ++
> >  include/linux/vfio.h|  6 
> >  include/uapi/linux/vfio.h   | 37 ++
> >  5 files changed, 123 insertions(+)
> >
> > diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig index
> > 3d8a108..95d90c6 100644
> > --- a/drivers/vfio/Kconfig
> > +++ b/drivers/vfio/Kconfig
> > @@ -2,6 +2,7 @@
> >  config VFIO_IOMMU_TYPE1
> > tristate
> > depends on VFIO
> > +   select VFIO_PASID if (X86)
> > default n
> >
> >  config VFIO_IOMMU_SPAPR_TCE
> > diff --git a/drivers/vfio/vfio_iommu_type1.c
> > b/drivers/vfio/vfio_iommu_type1.c index 18ff0c3..ea89c7c 100644
> > --- a/drivers/vfio/vfio_iommu_type1.c
> > +++ b/drivers/vfio/vfio_iommu_type1.c
> > @@ -76,6 +76,7 @@ struct vfio_iommu {
> > booldirty_page_tracking;
> > boolpinned_page_dirty_scope;
> > struct iommu_nesting_info   *nesting_info;
> > +   struct vfio_mm  *vmm;
> >  };
> >
> >  struct vfio_domain {
> > @@ -1937,6 +1938,11 @@ static void vfio_iommu_iova_insert_copy(struct
> > vfio_iommu *iommu,
> >
> >  static void vfio_iommu_release_nesting_info(struct vfio_iommu *iommu)
> > {
> > +   if (iommu->vmm) {
> > +   vfio_mm_put(iommu->vmm);
> > +   iommu->vmm = NULL;
> > +   }
> > +
> > kfree(iommu->nesting_info);
> > iommu->nesting_info = NULL;
> >  }
> > @@ -2071,6 +2077,26 @@ static int vfio_iommu_type1_attach_group(void
> *iommu_data,
> > iommu->nesting_info);
> > if (ret)
> > goto out_detach;
> > +
> > +   if (iommu->nesting_info->features &
> > +   IOMMU_NESTING_FEAT_SYSWIDE_PASID)
> {
> > +   struct vfio_mm *vmm;
> > +   int sid;
> > +
> > +   vmm = vfio_mm_get_from_task(current);
> > +   if (IS_ERR(vmm)) {
> > +   ret = PTR_ERR(vmm);
> > +   goto out_detach;
> > +   }
> > +   iommu->vmm = vmm;
> > +
> > +   sid = vfio_mm_ioasid_sid(vmm);
> > +   ret = iommu_domain_set_attr(domain->domain,
> > +   DOMAIN_ATTR_IOASID_SID,
> > +   &sid);
> > +   if (ret)
> > +   goto out_detach;
> > +   }
> > }
> >
> > /* Get aperture info */
> > @@ -2859,6 +2885,47 @@ static int vfio_iommu_type1_dirty_pages(struct
> vfio_iommu *iommu,
> > return -EINVAL;
> >  }
> >
> > +static int vfio_iommu_type1_pasid_request(struct vfio_iommu *iommu,
> > + unsigned long arg)
> > +{
> > +   struct vfio_iommu_type1_pasid_request req;
> > +   unsigned long minsz;
> > +   int ret;
> > +
> > +   minsz = offsetofend(struct vfio_iommu_type1_pasid_request, range);
> > +
> > +   if (copy_from_user(&req, (void __user *)arg, minsz))
> > +   return -EFAULT;
> > +
> > +   if (req.argsz < minsz || (req.flags & ~VFIO_PASID_REQUEST_MASK))
> > +   return -EINVAL;
> > +
> > +   if (req.range.min > req.range.max)
> > +

[RESEND PATCH v12 2/2] mtd: rawnand: Add NAND controller support on Intel LGM SoC

2020-08-16 Thread Ramuthevar,Vadivel MuruganX
From: Ramuthevar Vadivel Murugan 

This patch adds the new IP of Nand Flash Controller(NFC) support
on Intel's Lightning Mountain(LGM) SoC.

DMA is used for burst data transfer operation, also DMA HW supports
aligned 32bit memory address and aligned data access by default.
DMA burst of 8 supported. Data register used to support the read/write
operation from/to device.

NAND controller driver implements ->exec_op() to replace legacy hooks,
these specific call-back method to execute NAND operations.

Signed-off-by: Ramuthevar Vadivel Murugan 

---
 drivers/mtd/nand/raw/Kconfig |   8 +
 drivers/mtd/nand/raw/Makefile|   1 +
 drivers/mtd/nand/raw/intel-nand-controller.c | 757 +++
 3 files changed, 766 insertions(+)
 create mode 100644 drivers/mtd/nand/raw/intel-nand-controller.c

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 85280e327bfe..8cd77a4a1bbd 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -460,6 +460,14 @@ config MTD_NAND_ARASAN
  Enables the driver for the Arasan NAND flash controller on
  Zynq Ultrascale+ MPSoC.
 
+config MTD_NAND_INTEL_LGM
+   tristate "Support for NAND controller on Intel LGM SoC"
+   depends on OF || COMPILE_TEST
+   depends on HAS_IOMEM
+   help
+ Enables support for NAND Flash chips on Intel's LGM SoC.
+ NAND flash controller interfaced through the External Bus Unit.
+
 comment "Misc"
 
 config MTD_SM_COMMON
diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile
index 2930f5b9015d..9e6037363fc6 100644
--- a/drivers/mtd/nand/raw/Makefile
+++ b/drivers/mtd/nand/raw/Makefile
@@ -58,6 +58,7 @@ obj-$(CONFIG_MTD_NAND_STM32_FMC2) += stm32_fmc2_nand.o
 obj-$(CONFIG_MTD_NAND_MESON)   += meson_nand.o
 obj-$(CONFIG_MTD_NAND_CADENCE) += cadence-nand-controller.o
 obj-$(CONFIG_MTD_NAND_ARASAN)  += arasan-nand-controller.o
+obj-$(CONFIG_MTD_NAND_INTEL_LGM)   += intel-nand-controller.o
 
 nand-objs := nand_base.o nand_legacy.o nand_bbt.o nand_timings.o nand_ids.o
 nand-objs += nand_onfi.o
diff --git a/drivers/mtd/nand/raw/intel-nand-controller.c 
b/drivers/mtd/nand/raw/intel-nand-controller.c
new file mode 100644
index ..6f9e3c95e3a5
--- /dev/null
+++ b/drivers/mtd/nand/raw/intel-nand-controller.c
@@ -0,0 +1,757 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Copyright (c) 2020 Intel Corporation. */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define EBU_CLC0x000
+#define EBU_CLC_RST0xu
+
+#define EBU_ADDR_SEL(n)(0x20 + (n) * 4)
+/* 5 bits 26:22 included for comparison in the ADDR_SELx */
+#define EBU_ADDR_MASK(x)   ((x) << 4)
+#define EBU_ADDR_SEL_REGEN 0x1
+
+#define EBU_BUSCON(n)  (0x60 + (n) * 4)
+#define EBU_BUSCON_CMULT_V40x1
+#define EBU_BUSCON_RECOVC(n)   ((n) << 2)
+#define EBU_BUSCON_HOLDC(n)((n) << 4)
+#define EBU_BUSCON_WAITRDC(n)  ((n) << 6)
+#define EBU_BUSCON_WAITWRC(n)  ((n) << 8)
+#define EBU_BUSCON_BCGEN_CS0x0
+#define EBU_BUSCON_SETUP_ENBIT(22)
+#define EBU_BUSCON_ALEC0xC000
+
+#define EBU_CON0x0B0
+#define EBU_CON_NANDM_EN   BIT(0)
+#define EBU_CON_NANDM_DIS  0x0
+#define EBU_CON_CSMUX_E_EN BIT(1)
+#define EBU_CON_ALE_P_LOW  BIT(2)
+#define EBU_CON_CLE_P_LOW  BIT(3)
+#define EBU_CON_CS_P_LOW   BIT(4)
+#define EBU_CON_SE_P_LOW   BIT(5)
+#define EBU_CON_WP_P_LOW   BIT(6)
+#define EBU_CON_PRE_P_LOW  BIT(7)
+#define EBU_CON_IN_CS_S(n) ((n) << 8)
+#define EBU_CON_OUT_CS_S(n)((n) << 10)
+#define EBU_CON_LAT_EN_CS_P((0x3D) << 18)
+
+#define EBU_WAIT   0x0B4
+#define EBU_WAIT_RDBY  BIT(0)
+#define EBU_WAIT_WR_C  BIT(3)
+
+#define HSNAND_CTL10x110
+#define HSNAND_CTL1_ADDR_SHIFT 24
+
+#define HSNAND_CTL20x114
+#define HSNAND_CTL2_ADDR_SHIFT 8
+#define HSNAND_CTL2_CYC_N_V5   (0x2 << 16)
+
+#define HSNAND_INT_MSK_CTL 0x124
+#define HSNAND_INT_MSK_CTL_WR_CBIT(4)
+
+#define HSNAND_INT_STA 0x128
+#define HSNAND_INT_STA_WR_CBIT(4)
+
+#define HSNAND_CTL 0x130
+#define HSNAND_CTL_ENABLE_ECC  BIT(0)
+#define HSNAND_CTL_GO  BIT(2)
+#define HSNAND_CTL_CE_SEL_CS(n)BIT(3 + (n))
+#define HSNAND_CTL_RW_READ 0x0
+#define HSNAND_CTL_RW_WRITEBIT(10)
+#define HSNAND_CTL_ECC_OFF_V8THBIT(11)
+#define HSNAND_CTL_CKFF_EN 0x0
+#define HSNAND_CTL_MSG_EN  BIT(17)
+
+#define HSNAND_PARA0   0x13c
+#define HSNAND_PARA0_PAGE_V81920x3
+#define HSNAND_PARA0_PIB_V256  (0x3 << 4)
+#define HSNAND_PARA0_BYP_EN_NP 0x0
+#define HSNAND_PARA0_BYP_DEC_NP0x0
+#define HSNAND_PARA0_TYP

[RESEND PATCH v12 1/2] dt-bindings: mtd: Add Nand Flash Controller support for Intel LGM SoC

2020-08-16 Thread Ramuthevar,Vadivel MuruganX
From: Ramuthevar Vadivel Murugan 

Add YAML file for dt-bindings to support NAND Flash Controller
on Intel's Lightning Mountain SoC.

Signed-off-by: Ramuthevar Vadivel Murugan 

Reviewed-by: Rob Herring 
---
 .../devicetree/bindings/mtd/intel,lgm-nand.yaml| 99 ++
 1 file changed, 99 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/intel,lgm-nand.yaml

diff --git a/Documentation/devicetree/bindings/mtd/intel,lgm-nand.yaml 
b/Documentation/devicetree/bindings/mtd/intel,lgm-nand.yaml
new file mode 100644
index ..313daec4d783
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/intel,lgm-nand.yaml
@@ -0,0 +1,99 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mtd/intel,lgm-nand.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Intel LGM SoC NAND Controller Device Tree Bindings
+
+allOf:
+  - $ref: "nand-controller.yaml"
+
+maintainers:
+  - Ramuthevar Vadivel Murugan 
+
+properties:
+  compatible:
+const: intel,lgm-nand
+
+  reg:
+maxItems: 6
+
+  reg-names:
+items:
+   - const: ebunand
+   - const: hsnand
+   - const: nand_cs0
+   - const: nand_cs1
+   - const: addr_sel0
+   - const: addr_sel1
+
+  clocks:
+maxItems: 1
+
+  dmas:
+maxItems: 2
+
+  dma-names:
+items:
+  - const: tx
+  - const: rx
+
+  "#address-cells":
+const: 1
+
+  "#size-cells":
+const: 0
+
+patternProperties:
+  "^nand@[a-f0-9]+$":
+type: object
+properties:
+  reg:
+minimum: 0
+maximum: 7
+
+  nand-ecc-mode: true
+
+  nand-ecc-algo:
+const: hw
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - clocks
+  - dmas
+  - dma-names
+  - "#address-cells"
+  - "#size-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+nand-controller@e0f0 {
+  compatible = "intel,lgm-nand";
+  reg = <0xe0f0 0x100>,
+<0xe100 0x300>,
+<0xe140 0x8000>,
+<0xe1c0 0x1000>,
+<0x1740 0x4>,
+<0x17c0 0x4>;
+  reg-names = "ebunand", "hsnand", "nand_cs0", "nand_cs1",
+"addr_sel0", "addr_sel1";
+  clocks = <&cgu0 125>;
+  dmas = <&dma0 8>, <&dma0 9>;
+  dma-names = "tx", "rx";
+  #address-cells = <1>;
+  #size-cells = <0>;
+
+  nand@0 {
+reg = <0>;
+nand-ecc-mode = "hw";
+  };
+};
+
+...
-- 
2.11.0



[RESEND PATCH v12 0/2] mtd: rawnand: Add NAND controller support on Intel LGM SoC

2020-08-16 Thread Ramuthevar,Vadivel MuruganX
This patch adds the new IP of Nand Flash Controller(NFC) support
on Intel's Lightning Mountain(LGM) SoC.

DMA is used for burst data transfer operation, also DMA HW supports
aligned 32bit memory address and aligned data access by default.
DMA burst of 8 supported. Data register used to support the read/write
operation from/to device.

NAND controller also supports in-built HW ECC engine.

NAND controller driver implements ->exec_op() to replace legacy hooks,
these specific call-back method to execute NAND operations.

Thanks Miquel, Boris, Andy, Arnd and Rob for the review comments and 
suggestions.
---
v12-resend:
  - No Change
v12:
  - address Miquel Raynal review comments update
  - add/modify the comments for better understanding
  - handle the check_only variable
  - update the ecc function based on the existing drivers
  - add newline
  - verify that mtd->name is set after nand_set_flash_node()
  - add the check WARN_ON(ret);
v11-resend:
  - Rebase to v5.8-rc1
v11:
  - No Change
v10:
  - No Change
v9:
  - No change
v8:
  - fix the kbuild bot warnings
  - correct the typo's
v7:
  - indentation issue is fixed
  - add error check for retrieve the resource from dt
v6:
  - update EBU_ADDR_SELx register base value build it from DT
  - Add tabs in in Kconfig
v5:
  - replace by 'HSNAND_CLE_OFFS | HSNAND_CS_OFFS' to NAND_WRITE_CMD and 
NAND_WRITE_ADDR
  - remove the unused macros
  - update EBU_ADDR_MASK(x) macro
  - update the EBU_ADDR_SELx register values to be written
v4:
  - add ebu_nand_cs structure for multiple-CS support
  - mask/offset encoding for 0x51 value
  - update macro HSNAND_CTL_ENABLE_ECC
  - drop the op argument and un-used macros.
  - updated the datatype and macros
  - add function disable nand module
  - remove ebu_host->dma_rx = NULL;
  - rename MMIO address range variables to ebu and hsnand
  - implement ->setup_data_interface()
  - update label err_cleanup_nand and err_cleanup_dma
  - add return value check in the nand_remove function
  - add/remove tabs and spaces as per coding standard
  - encoded CS ids by reg property
v3:
  - Add depends on MACRO in Kconfig
  - file name update in Makefile
  - file name update to intel-nand-controller
  - modification of MACRO divided like EBU, HSNAND and NAND
  - add NAND_ALE_OFFS, NAND_CLE_OFFS and NAND_CS_OFFS
  - rename lgm_ to ebu_ and _va suffix is removed in the whole file
  - rename structure and varaibles as per review comments.
  - remove lgm_read_byte(), lgm_dev_ready() and cmd_ctrl() un-used function
  - update in exec_op() as per review comments
  - rename function lgm_dma_exit() by lgm_dma_cleanup()
  - hardcoded magic value  for base and offset replaced by MACRO defined
  - mtd_device_unregister() + nand_cleanup() instead of nand_release()
v2:
  - implement the ->exec_op() to replaces the legacy hook-up.
  - update the commit message
  - add MIPS maintainers and xway_nand driver author in CC
v1:
 - initial version


dt-bindings: mtd: Add Nand Flash Controller support for Intel LGM SoC
---
v12-Resend:
  - No Change
v12:
  - No change
v11-resend:
  - No change
v11:
  - Fixed the compatible issue with example
10:
  - fix bot errors
v9:
  - Rob's review comments address
  - dual licensed
  - compatible change
  - add reg-names
  - drop clock-names and clock-cells
  - correct typo's
v8:
  No change
v7:
  - Rob's review comments addressed
  - dt-schema build issue fixed with upgraded dt-schema
v6:
  - Rob's review comments addressed in YAML file
  - add addr_sel0 and addr_sel1 reg-names in YAML example
v5:
  - add the example in YAML file
v4:
  - No change
v3:
  - No change
v2:
  YAML compatible string update to intel, lgm-nand-controller
v1:
  - initial version
 


Ramuthevar Vadivel Murugan (2):
  dt-bindings: mtd: Add Nand Flash Controller support for Intel LGM SoC
  mtd: rawnand: Add NAND controller support on Intel LGM SoC

 .../devicetree/bindings/mtd/intel,lgm-nand.yaml|  99 +++
 drivers/mtd/nand/raw/Kconfig   |   8 +
 drivers/mtd/nand/raw/Makefile  |   1 +
 drivers/mtd/nand/raw/intel-nand-controller.c   | 757 +
 4 files changed, 865 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/intel,lgm-nand.yaml
 create mode 100644 drivers/mtd/nand/raw/intel-nand-controller.c

-- 
2.11.0



[PATCH V3 3/3] x86/entry: remove unused sync_regs()

2020-08-16 Thread Lai Jiangshan
From: Lai Jiangshan 

No more users.

Signed-off-by: Lai Jiangshan 
---
 arch/x86/include/asm/traps.h |  1 -
 arch/x86/kernel/traps.c  | 13 -
 2 files changed, 14 deletions(-)

diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h
index 714b1a30e7b0..52cd29bde1d0 100644
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -10,7 +10,6 @@
 #include/* TRAP_TRACE, ... */
 
 #ifdef CONFIG_X86_64
-asmlinkage __visible notrace struct pt_regs *sync_regs(struct pt_regs *eregs);
 asmlinkage __visible notrace
 struct bad_iret_stack *fixup_bad_iret(struct bad_iret_stack *s);
 void __init trap_init(void);
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 852de6f1bf88..ebea1c3e473b 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -660,19 +660,6 @@ DEFINE_IDTENTRY_RAW(exc_int3)
 }
 
 #ifdef CONFIG_X86_64
-/*
- * Help handler running on a per-cpu (IST or entry trampoline) stack
- * to switch to the normal thread stack if the interrupted code was in
- * user mode. The actual stack switch is done in entry_64.S
- */
-asmlinkage __visible noinstr struct pt_regs *sync_regs(struct pt_regs *eregs)
-{
-   struct pt_regs *regs = (struct pt_regs 
*)this_cpu_read(cpu_current_top_of_stack) - 1;
-   if (regs != eregs)
-   *regs = *eregs;
-   return regs;
-}
-
 struct bad_iret_stack {
void *error_entry_ret;
struct pt_regs regs;
-- 
2.19.1.6.gb485710b



[PATCH V3 1/3] x86/entry: avoid calling into sync_regs() when entering from userspace

2020-08-16 Thread Lai Jiangshan
From: Lai Jiangshan 

7f2590a110b8("x86/entry/64: Use a per-CPU trampoline stack for IDT entries")
made a change that when any exception happens on userspace, the
entry code will save the pt_regs on the sp0 stack, and then copy it
to the thread stack via sync_regs() and switch to thread stack
afterward.

And recent x86/entry work makes interrupt also use idtentry
and makes all the interrupt code save the pt_regs on the sp0 stack
and then copy it to the thread stack like exception.

This is hot path (page fault, ipi), such overhead should be avoided.
This patch borrows the way how original interrupt_entry handles it.
It switches to the thread stack directly right away when comes
from userspace.

Signed-off-by: Lai Jiangshan 
---
 arch/x86/entry/entry_64.S | 43 +++
 1 file changed, 34 insertions(+), 9 deletions(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 70dea9337816..1a7715430da3 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -928,19 +928,42 @@ SYM_CODE_END(paranoid_exit)
 SYM_CODE_START_LOCAL(error_entry)
UNWIND_HINT_FUNC
cld
-   PUSH_AND_CLEAR_REGS save_ret=1
-   ENCODE_FRAME_POINTER 8
-   testb   $3, CS+8(%rsp)
+   testb   $3, CS-ORIG_RAX+8(%rsp)
jz  .Lerror_kernelspace
 
-   /*
-* We entered from user mode or we're pretending to have entered
-* from user mode due to an IRET fault.
-*/
SWAPGS
FENCE_SWAPGS_USER_ENTRY
-   /* We have user CR3.  Change to kernel CR3. */
-   SWITCH_TO_KERNEL_CR3 scratch_reg=%rax
+   /*
+* Switch to the thread stack. The IRET frame and orig_ax are
+* on the stack, as well as the return address. RDI..R12 are
+* not (yet) on the stack and space has not (yet) been
+* allocated for them.
+*/
+   pushq   %rdx
+
+   /* Need to switch before accessing the thread stack. */
+   SWITCH_TO_KERNEL_CR3 scratch_reg=%rdx
+   movq%rsp, %rdx
+   movqPER_CPU_VAR(cpu_current_top_of_stack), %rsp
+
+/*
+ * We have RDX, return address, and orig_ax on the stack on
+ * top of the IRET frame. That means offset=24
+ */
+   UNWIND_HINT_IRET_REGS base=%rdx offset=24
+
+   pushq   7*8(%rdx)   /* regs->ss */
+   pushq   6*8(%rdx)   /* regs->rsp */
+   pushq   5*8(%rdx)   /* regs->eflags */
+   pushq   4*8(%rdx)   /* regs->cs */
+   pushq   3*8(%rdx)   /* regs->ip */
+   pushq   2*8(%rdx)   /* regs->orig_ax */
+   pushq   8(%rdx) /* return address */
+   UNWIND_HINT_FUNC
+
+   PUSH_AND_CLEAR_REGS rdx=(%rdx), save_ret=1
+   ENCODE_FRAME_POINTER 8
+   ret
 
 .Lerror_entry_from_usermode_after_swapgs:
/* Put us onto the real thread stack. */
@@ -964,6 +987,8 @@ SYM_CODE_START_LOCAL(error_entry)
 * for these here too.
 */
 .Lerror_kernelspace:
+   PUSH_AND_CLEAR_REGS save_ret=1
+   ENCODE_FRAME_POINTER 8
leaqnative_irq_return_iret(%rip), %rcx
cmpq%rcx, RIP+8(%rsp)
je  .Lerror_bad_iret
-- 
2.19.1.6.gb485710b



[PATCH V3 2/3] x86/entry: directly switch to kernel stack when .Lerror_bad_iret

2020-08-16 Thread Lai Jiangshan
From: Lai Jiangshan 

Directly copy pt_regs to kernel stack when .Lerror_bad_iret.
Directly switch to kernel stack when .Lerror_bad_iret.

We can see that entry_64.S do the following things back to back
when .Lerror_bad_iret:
  call fixup_bad_iret(), switch to sp0 stack with pt_regs copied
  call sync_regs(), switch to kernel stack with pt_regs copied

So we can do the all things together in fixup_bad_iret().

After this patch, fixup_bad_iret() is restored to the behavior before
7f2590a110b8("x86/entry/64: Use a per-CPU trampoline stack for IDT entries")

Signed-off-by: Lai Jiangshan 
---
 arch/x86/entry/entry_64.S | 13 ++---
 arch/x86/kernel/traps.c   |  9 -
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 1a7715430da3..911cfa0da637 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -965,16 +965,6 @@ SYM_CODE_START_LOCAL(error_entry)
ENCODE_FRAME_POINTER 8
ret
 
-.Lerror_entry_from_usermode_after_swapgs:
-   /* Put us onto the real thread stack. */
-   popq%r12/* save return addr in %12 */
-   movq%rsp, %rdi  /* arg0 = pt_regs pointer */
-   callsync_regs
-   movq%rax, %rsp  /* switch stack */
-   ENCODE_FRAME_POINTER
-   pushq   %r12
-   ret
-
 .Lerror_entry_done_lfence:
FENCE_SWAPGS_KERNEL_ENTRY
 .Lerror_entry_done:
@@ -1028,7 +1018,8 @@ SYM_CODE_START_LOCAL(error_entry)
mov %rsp, %rdi
callfixup_bad_iret
mov %rax, %rsp
-   jmp .Lerror_entry_from_usermode_after_swapgs
+   ENCODE_FRAME_POINTER 8
+   ret
 SYM_CODE_END(error_entry)
 
 SYM_CODE_START_LOCAL(error_return)
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 1f66d2d1e998..852de6f1bf88 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -684,13 +684,12 @@ struct bad_iret_stack *fixup_bad_iret(struct 
bad_iret_stack *s)
/*
 * This is called from entry_64.S early in handling a fault
 * caused by a bad iret to user mode.  To handle the fault
-* correctly, we want to move our stack frame to where it would
-* be had we entered directly on the entry stack (rather than
-* just below the IRET frame) and we want to pretend that the
-* exception came from the IRET target.
+* correctly, we want to move our stack frame to kernel stack
+* (rather than just below the IRET frame) and we want to
+* pretend that the exception came from the IRET target.
 */
struct bad_iret_stack tmp, *new_stack =
-   (struct bad_iret_stack 
*)__this_cpu_read(cpu_tss_rw.x86_tss.sp0) - 1;
+   (struct bad_iret_stack 
*)__this_cpu_read(cpu_current_top_of_stack) - 1;
 
/* Copy the IRET target to the temporary storage. */
__memcpy(&tmp.regs.ip, (void *)s->regs.sp, 5*8);
-- 
2.19.1.6.gb485710b



Re: [PATCH v4 1/2] ASoC: mediatek: mt6359: add codec driver

2020-08-16 Thread Tzung-Bi Shih
On Sun, Aug 16, 2020 at 1:20 AM Jiaxin Yu  wrote:
>
> +static int mt6359_platform_driver_probe(struct platform_device *pdev)
[snip]
> +
> +   return devm_snd_soc_register_component(&pdev->dev,
> +  &mt6359_soc_component_driver,
> +  mt6359_dai_driver,
> +  ARRAY_SIZE(mt6359_dai_driver));
> +}
> +
> +static int mt6359_platform_driver_remove(struct platform_device *pdev)
> +{
> +   struct mt6359_priv *priv = dev_get_drvdata(&pdev->dev);
> +   int ret;
> +
> +   dev_dbg(&pdev->dev, "%s(), dev name %s\n",
> +   __func__, dev_name(&pdev->dev));
> +
> +   ret = regulator_disable(priv->avdd_reg);
> +   if (ret) {
> +   dev_err(&pdev->dev, "%s(), failed to disable regulator!\n",
> +   __func__);
> +   return ret;
> +   }
> +
> +   snd_soc_unregister_component(&pdev->dev);

You don't need to unregister the component which is already delegated to devm.


Re: [PATCH v2 0/2] dmaengine: ti: k3-psil: Add support for j7200

2020-08-16 Thread Vinod Koul
On 03-08-20, 15:57, Peter Ujfalusi wrote:
> Hi,
> 
> Changes since v1:
> - Drop unrelated empty line change in patch 1 (k3-psil.c)
> 
> j7200 uses the same DMA hardware but have different set of peripherals, 
> needing
> different PSI-L thread map compared to j721e.
> 
> To simplify the runtime PSI-L map selection we will switch to use
> soc_device_match.

Applied, thanks

-- 
~Vinod


Re: [PATCH V2] dmaengine: bcm-sba-raid: add missing put_device() call in sba_probe()

2020-08-16 Thread Vinod Koul
On 29-07-20, 20:49, Yu Kuai wrote:
> if of_find_device_by_node() succeed, sba_probe() doesn't have a
> corresponding put_device(). Thus add a jump target to fix the
> exception handling for this function implementation.

Applied, thanks

-- 
~Vinod


Re: [PATCH] dmaengine: at_hdmac: do exception handling appropriately in at_dma_xlate()

2020-08-16 Thread Vinod Koul
On 29-07-20, 20:29, Yu Kuai wrote:
> Do several things for exception handing:
> 
> a. check return value of of_find_device_by_node().
> b. call put_device() if memory allocation for 'atslave' failed.
> c. if dma_request_channel() failed, call put_device() and kfree().

One patch per change please

-- 
~Vinod


Re: [PATCH] dmaengine: ti: omap-dma: Drop of_match_ptr to fix -Wunused-const-variable

2020-08-16 Thread Vinod Koul
On 28-07-20, 19:09, Krzysztof Kozlowski wrote:
> The of_device_id is included unconditionally by of.h header and used
> in the driver as well.  Remove of_match_ptr to fix W=1 compile test
> warning with !CONFIG_OF:
> 
> drivers/dma/ti/omap-dma.c:1892:34: warning: 'omap_dma_match' defined but 
> not used [-Wunused-const-variable=]
>  1892 | static const struct of_device_id omap_dma_match[] = {

Applied, thanks

-- 
~Vinod


Re: [RFC 0/5] Introduce NMI aware serial drivers

2020-08-16 Thread Sumit Garg
On Fri, 14 Aug 2020 at 19:48, Daniel Thompson
 wrote:
>
> On Fri, Aug 14, 2020 at 05:36:36PM +0530, Sumit Garg wrote:
> > On Thu, 13 Aug 2020 at 15:47, Daniel Thompson
> >  wrote:
> > >
> > > On Thu, Aug 13, 2020 at 02:55:12PM +0530, Sumit Garg wrote:
> > > > On Thu, 13 Aug 2020 at 05:38, Doug Anderson  
> > > > wrote:
> > > > > On Wed, Aug 12, 2020 at 8:27 AM Doug Anderson  
> > > > > wrote:
> > > > > > One
> > > > > > last worry is that I assume that most people testing (and even
> > > > > > automated testing labs) will either always enable NMI or won't 
> > > > > > enable
> > > > > > NMI.  That means that everyone will be only testing one codepath or
> > > > > > the other and (given the complexity) the non-tested codepath will
> > > > > > break.
> > > > > >
> > > >
> > > > The current patch-set only makes this NMI to work when debugger (kgdb)
> > > > is enabled which I think is mostly suitable for development
> > > > environments. So most people testing will involve existing IRQ mode
> > > > only.
> > > >
> > > > However, it's very much possible to make NMI mode as default for a
> > > > particular serial driver if the underlying irqchip supports it but it
> > > > depends if we really see any production level usage of NMI debug
> > > > feature.
> > >
> > > The effect of this patch is not to make kgdb work from NMI it is to make
> > > (some) SysRqs work from NMI. I think that only allowing it to deploy for
> > > kgdb users is a mistake.
> > >
> > > Having it deploy automatically for kgdb users might be OK but it seems
> > > sensible to make this feature available for other users too.
> >
> > I think I wasn't clear enough in my prior reply. Actually I meant to
> > say that this patch-set enables NMI support for a particular serial
> > driver via ".poll_init()" interface and the only current user of that
> > interface is kgdb.
> >
> > So if there are other users interested in this feature, they can use
> > ".poll_init()" interface as well to enable it.
>
> Huh?
>
> We appear to speaking interchangably about users (people who sit in
> front of the machine and want a stack trace) and sub-systems ;-).
>
> I don't think other SysRq commands have quite such a direct relationship
> between the sub-system and the sysrq command. For example who are you
> expecting to call .poll_init() if a user wants to use the SysRq to
> provoke a stack trace?
>

Ah, I see. So you meant to provide a user-space interface to
dynamically enable/disable NMI debug, correct? It will require IRQ <->
NMI switching at runtime which should be doable safely.

-Sumit

>
> Daniel.


Re: [PATCH 2/4] opp: Track device's resources configuration status

2020-08-16 Thread Viresh Kumar
On 15-08-20, 01:03, Stephen Boyd wrote:
> Quoting Viresh Kumar (2020-08-12 21:28:59)
> > The OPP core needs to track if the resources of devices are enabled or
> > configured or not, as it disables the resources when target_freq is set
> > to 0.
> > 
> > Handle that with a separate variable to make it easy to maintain.
> > 
> > Also note that we will unconditionally call clk_set_rate() in the case
> > where the resources are getting enabled again. This shouldn't have any
> > side effects anyway.
> 
> Any reason to want to do that?

To avoid more flags, code paths and simplicity of the code. And this
should normally happen in a corner case as well, like calling
set-rate(0) from suspend and then reinitializing things again in
resume.

> We'll have to grab the prepare lock in
> the clk framework to figure out that there's nothing to do sometimes. If
> anything, a comment may help to indicate that we call clk_set_rate()
> again, but don't expect it to matter much.

Ok.

-- 
viresh


Re: [PATCH] upcall: Remove unneeded variable insize

2020-08-16 Thread kernel test robot
Hi Xu,

Thank you for the patch! Yet something to improve:

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

url:
https://github.com/0day-ci/linux/commits/Xu-Wang/upcall-Remove-unneeded-variable-insize/20200817-112244
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
9123e3a74ec7b934a4a099e98af6a61c2f80bbf5
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross 
ARCH=xtensa 

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

All errors (new ones prefixed by >>):

   fs/coda/upcall.c: In function 'venus_setattr':
   fs/coda/upcall.c:115:27: warning: variable 'outp' set but not used 
[-Wunused-but-set-variable]
 115 | union outputArgs *outp;
 |   ^~~~
   fs/coda/upcall.c: In function 'venus_close':
   fs/coda/upcall.c:164:20: warning: variable 'outp' set but not used 
[-Wunused-but-set-variable]
 164 |  union outputArgs *outp;
 |^~~~
   fs/coda/upcall.c: In function 'venus_rename':
   fs/coda/upcall.c:238:27: warning: variable 'outp' set but not used 
[-Wunused-but-set-variable]
 238 | union outputArgs *outp;
 |   ^~~~
   fs/coda/upcall.c: In function 'venus_rmdir':
   fs/coda/upcall.c:306:27: warning: variable 'outp' set but not used 
[-Wunused-but-set-variable]
 306 | union outputArgs *outp;
 |   ^~~~
   fs/coda/upcall.c: In function 'venus_remove':
   fs/coda/upcall.c:329:27: warning: variable 'outp' set but not used 
[-Wunused-but-set-variable]
 329 | union outputArgs *outp;
 |   ^~~~
   fs/coda/upcall.c: In function 'venus_link':
   fs/coda/upcall.c:383:27: warning: variable 'outp' set but not used 
[-Wunused-but-set-variable]
 383 | union outputArgs *outp;
 |   ^~~~
   fs/coda/upcall.c: In function 'venus_symlink':
   fs/coda/upcall.c:410:27: warning: variable 'outp' set but not used 
[-Wunused-but-set-variable]
 410 | union outputArgs *outp;
 |   ^~~~
   fs/coda/upcall.c: In function 'venus_fsync':
   fs/coda/upcall.c:443:27: warning: variable 'outp' set but not used 
[-Wunused-but-set-variable]
 443 | union outputArgs *outp;
 |   ^~~~
   fs/coda/upcall.c: In function 'venus_access':
   fs/coda/upcall.c:459:27: warning: variable 'outp' set but not used 
[-Wunused-but-set-variable]
 459 | union outputArgs *outp;
 |   ^~~~
   fs/coda/upcall.c: In function 'venus_pioctl':
>> fs/coda/upcall.c:63:44: error: 'insize' undeclared (first use in this 
>> function); did you mean 'iocsize'?
  63 |  inp = (union inputArgs *)alloc_upcall(op, insize); \
 |^~
   fs/coda/upcall.c:483:2: note: in expansion of macro 'UPARG'
 483 |  UPARG(CODA_IOCTL);
 |  ^
   fs/coda/upcall.c:63:44: note: each undeclared identifier is reported only 
once for each function it appears in
  63 |  inp = (union inputArgs *)alloc_upcall(op, insize); \
 |^~
   fs/coda/upcall.c:483:2: note: in expansion of macro 'UPARG'
 483 |  UPARG(CODA_IOCTL);
 |  ^
   fs/coda/upcall.c: In function 'venus_access_intent':
   fs/coda/upcall.c:576:20: warning: variable 'outp' set but not used 
[-Wunused-but-set-variable]
 576 |  union outputArgs *outp;
 |^~~~

# 
https://github.com/0day-ci/linux/commit/e126bb2bc1e15e86a4267e92df88f4987d01b358
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Xu-Wang/upcall-Remove-unneeded-variable-insize/20200817-112244
git checkout e126bb2bc1e15e86a4267e92df88f4987d01b358
vim +63 fs/coda/upcall.c

^1da177e4c3f41 Linus Torvalds 2005-04-16  60  
^1da177e4c3f41 Linus Torvalds 2005-04-16  61  #define UPARG(op)\
^1da177e4c3f41 Linus Torvalds 2005-04-16  62  do {\
^1da177e4c3f41 Linus Torvalds 2005-04-16 @63inp = (union inputArgs 
*)alloc_upcall(op, insize); \
^1da177e4c3f41 Linus Torvalds 2005-04-16  64  if (IS_ERR(inp)) { return 
PTR_ERR(inp); }\
^1da177e4c3f41 Linus Torvalds 2005-04-16  65  outp = (union outputArgs 
*)(inp); \
^1da177e4c3f41 Linus Torvalds 2005-04-16  66  ou

Re: [PATCH v1] dmaengine: pch_dma: use generic power management

2020-08-16 Thread Vinod Koul
On 27-07-20, 14:19, Andy Shevchenko wrote:
> On Mon, Jul 27, 2020 at 1:16 PM Vinod Koul  wrote:
> > On 20-07-20, 17:07, Vaibhav Gupta wrote:
> > > Drivers using legacy PM have to manage PCI states and device's PM states
> > > themselves. They also need to take care of configuration registers.
> > >
> > > With improved and powerful support of generic PM, PCI Core takes care of
> > > above mentioned, device-independent, jobs.
> > >
> > > This driver makes use of PCI helper functions like
> > > pci_save/restore_state(), pci_enable/disable_device(),
> > > and pci_set_power_state() to do required operations. In generic mode, they
> > > are no longer needed.
> > >
> > > Change function parameter in both .suspend() and .resume() to
> > > "struct device*" type. Use dev_get_drvdata() to get drv data.
> >
> > You are doing too many things in One patch. Do consider splitting them
> > up to a change per patch. for example using __maybe could be one patch,
> > removing code is suspend-resume callbacks would be other one.
> 
> Vinod, while I completely agree with you in general, in this case it
> would make more unnecessary churn and will be rather unhelpful in all
> ways: for the contributor to do this work, for the reader to collect
> all the pieces. It also will be a bisectability issue, because the
> #ifdeffery replacement (IIRC you need to move from CONFIG_PM to
> CONFIG_PM_SLEEP). I really don't see any advantages of the splitting
> here.
> 
> > > Compile-tested only.
> >
> > I would like to see some testing before we merge this
> 
> I have hardware to test (Intel Minnowboard v1) but have no time. And
> taking into account that I did similar changes for many other drivers,
> I can give my
> Reviewed-by: Andy Shevchenko 
> and take responsibility if somebody complains in the future (I don't
> believe it will be one).
> 
> P.S. Another scenario if Vaibhav can find that board (there were
> dozens of thousands at least produced and floating on the second hand
> market) and test himself. It may be good since he touches the full lot
> of PCH (EGT20) drivers.

Applied now, thanks

-- 
~Vinod


Re: [PATCH] dmaengine: acpi: Put the CSRT table after using it

2020-08-16 Thread Vinod Koul
On 22-07-20, 17:54, Hanjun Guo wrote:
> The acpi_get_table() should be coupled with acpi_put_table() if
> the mapped table is not used at runtime to release the table
> mapping, put the CSRT table buf after using it.

Applied, thanks

-- 
~Vinod


[PATCH v4] kthread: Add debugobject support

2020-08-16 Thread Qianli Zhao
From: Qianli Zhao 

Add debugobject support to track the life time of kthread_work
which is used to detect reinitialization/free active object problems
Add kthread_init_work_onstack()/kthread_init_delayed_work_onstack() for
kthread onstack support

If we reinitialize a kthread_work that has been activated,
this will cause delayed_work_list/work_list corruption.
enable this config,there is an chance to fixup these errors
or WARNING the wrong use of kthread_work

[30858.395766] list_del corruption. next->prev should be ffe388ebbf88, but 
was ffe388ebb588
[30858.395788] WARNING: CPU: 2 PID: 387 at 
/home/work/data/codes/build_home/kernel/msm-4.19/lib/list_debug.c:56 
__list_del_entry_valid+0xc8/0xd0
...
[30858.395906] Call trace:
[30858.395909]  __list_del_entry_valid+0xc8/0xd0
[30858.395912]  __kthread_cancel_work_sync+0x98/0x138
[30858.395915]  kthread_cancel_delayed_work_sync+0x10/0x20
[30858.395917]  sde_encoder_resource_control+0xe8/0x12c0
[30858.395920]  sde_encoder_prepare_for_kickoff+0x5dc/0x2008
[30858.395923]  sde_crtc_commit_kickoff+0x280/0x890
[30858.395925]  sde_kms_commit+0x16c/0x278
[30858.395928]  complete_commit+0x3c4/0x760
[30858.395931]  _msm_drm_commit_work_cb+0xec/0x1e0
[30858.395933]  kthread_worker_fn+0xf8/0x190
[30858.395935]  kthread+0x118/0x128
[30858.395938]  ret_from_fork+0x10/0x18

crash> struct kthread_worker.delayed_work_list 0xffe3893925f0
 [ffe389392620] delayed_work_list = {
next = 0xffe388ebbf88,
prev = 0xffe388ebb588
  }
crash> list 0xffe388ebbf88
ffe388ebbf88

Signed-off-by: Qianli Zhao 
---
V4:
- Changelog update
- Add comment for KWORK_ENTRY_STATIC
- Code format modification 
- Check worker availability early in kthread_flush_work

V3:
- changelog update
- add fixup_assert_init support
- move debug_kwork_activate/debug_kwork_deactivate before list operation
- name the kconfig CONFIG_DEBUG_OBJECTS_KTHREAD_WORK
- use kthread_init_work_onstack/destroy_kwork_on_stack when kthread_work used 
on stack
- __init_kwork before clear kthread_work in kthread_init_work
---
 include/linux/kthread.h |  30 ++-
 include/linux/poison.h  |   4 ++
 kernel/kthread.c| 135 ++--
 lib/Kconfig.debug   |  10 
 4 files changed, 173 insertions(+), 6 deletions(-)

diff --git a/include/linux/kthread.h b/include/linux/kthread.h
index 65b81e0..706302b 100644
--- a/include/linux/kthread.h
+++ b/include/linux/kthread.h
@@ -108,6 +108,17 @@ struct kthread_delayed_work {
struct timer_list timer;
 };
 
+#ifdef CONFIG_DEBUG_OBJECTS_KTHREAD_WORK
+extern void __init_kwork(struct kthread_work *kwork, int onstack);
+extern void destroy_kwork_on_stack(struct kthread_work *kwork);
+extern void destroy_delayed_kwork_on_stack(struct kthread_delayed_work 
*kdwork);
+#else
+static inline void __init_kwork(struct kthread_work *kwork, int onstack) { }
+static inline void destroy_kwork_on_stack(struct kthread_work *kwork) { }
+static inline void destroy_delayed_kwork_on_stack(struct kthread_delayed_work 
*kdwork) { }
+#endif
+
+
 #define KTHREAD_WORKER_INIT(worker){   \
.lock = __RAW_SPIN_LOCK_UNLOCKED((worker).lock),\
.work_list = LIST_HEAD_INIT((worker).work_list),\
@@ -115,7 +126,7 @@ struct kthread_delayed_work {
}
 
 #define KTHREAD_WORK_INIT(work, fn){   \
-   .node = LIST_HEAD_INIT((work).node),\
+   .node = { .next = KWORK_ENTRY_STATIC }, \
.func = (fn),   \
}
 
@@ -159,6 +170,15 @@ extern void __kthread_init_worker(struct kthread_worker 
*worker,
 
 #define kthread_init_work(work, fn)\
do {\
+   __init_kwork(work, 0);  
\
+   memset((work), 0, sizeof(struct kthread_work)); \
+   INIT_LIST_HEAD(&(work)->node);  \
+   (work)->func = (fn);\
+   } while (0)
+
+#define kthread_init_work_onstack(work, fn)
\
+   do {\
+   __init_kwork(work, 1);  
\
memset((work), 0, sizeof(struct kthread_work)); \
INIT_LIST_HEAD(&(work)->node);  \
(work)->func = (fn);\
@@ -172,6 +192,14 @@ extern void __kthread_init_worker(struct kthread_worker 
*worker,
 TIMER_IRQSAFE);\
} while (0)
 
+#define kthread_init_delayed_work_onstack(dwork, fn)   
\
+   do {

[PATCH] ALSA: hda/realtek: Add model alc298-samsung-headphone

2020-08-16 Thread Mike Pozulp
The very quiet and distorted headphone output bug that afflicted my
Samsung Notebook 9 is appearing in many other Samsung laptops. Expose
the quirk which fixed my laptop as a model so other users can try it.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207423
Signed-off-by: Mike Pozulp 
---
 sound/pci/hda/patch_realtek.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 29f5878f0c50..722d01a06422 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -7867,6 +7867,7 @@ static const struct hda_model_fixup alc269_fixup_models[] 
= {
{.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
{.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"},
{.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = 
"alc256-medion-headset"},
+   {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = 
"alc298-samsung-headphone"},
{}
 };
 #define ALC225_STANDARD_PINS \
-- 
2.28.0



[PATCH] lib: Convert test_printf.c to KUnit

2020-08-16 Thread Arpitha Raghunandan
Converts test lib/test_printf.c to KUnit.
More information about KUnit can be found at
https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html.
KUnit provides a common framework for unit tests in the kernel.

Signed-off-by: Arpitha Raghunandan <98.a...@gmail.com>
---
 lib/Kconfig.debug |   7 +-
 lib/Makefile  |   2 +-
 lib/{test_printf.c => printf_kunit.c} | 498 +-
 3 files changed, 246 insertions(+), 261 deletions(-)
 rename lib/{test_printf.c => printf_kunit.c} (45%)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index e068c3c7189a..7454258cf57a 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -2027,9 +2027,6 @@ config TEST_STRSCPY
 config TEST_KSTRTOX
tristate "Test kstrto*() family of functions at runtime"
 
-config TEST_PRINTF
-   tristate "Test printf() family of functions at runtime"
-
 config TEST_BITMAP
tristate "Test bitmap_*() family of functions at runtime"
help
@@ -2247,6 +2244,10 @@ config BITS_TEST
 
  If unsure, say N.
 
+config PRINTF_KUNIT_TEST
+   tristate "KUnit tests for printf() family of functions at runtime"
+   depends on KUNIT
+
 config TEST_UDELAY
tristate "udelay test driver"
help
diff --git a/lib/Makefile b/lib/Makefile
index e290fc5707ea..68e5b32a185f 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -77,7 +77,6 @@ obj-$(CONFIG_TEST_SORT) += test_sort.o
 obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
-obj-$(CONFIG_TEST_PRINTF) += test_printf.o
 obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
 obj-$(CONFIG_TEST_STRSCPY) += test_strscpy.o
 obj-$(CONFIG_TEST_BITFIELD) += test_bitfield.o
@@ -343,3 +342,4 @@ obj-$(CONFIG_PLDMFW) += pldmfw/
 obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o
 obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o
 obj-$(CONFIG_BITS_TEST) += test_bits.o
+obj-$(CONFIG_PRINTF_KUNIT_TEST) += printf_kunit.o
diff --git a/lib/test_printf.c b/lib/printf_kunit.c
similarity index 45%
rename from lib/test_printf.c
rename to lib/printf_kunit.c
index 7ac87f18a10f..68ac5f9b8d28 100644
--- a/lib/test_printf.c
+++ b/lib/printf_kunit.c
@@ -5,6 +5,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include 
 #include 
 #include 
 #include 
@@ -30,79 +31,61 @@
 #define PAD_SIZE 16
 #define FILL_CHAR '$'
 
-static unsigned total_tests __initdata;
-static unsigned failed_tests __initdata;
-static char *test_buffer __initdata;
-static char *alloced_buffer __initdata;
+static char *test_buffer;
+static char *alloced_buffer;
 
-static int __printf(4, 0) __init
-do_test(int bufsize, const char *expect, int elen,
+static void __printf(5, 0)
+do_test(struct kunit *kunittest, int bufsize, const char *expect, int elen,
const char *fmt, va_list ap)
 {
va_list aq;
int ret, written;
 
-   total_tests++;
-
memset(alloced_buffer, FILL_CHAR, BUF_SIZE + 2*PAD_SIZE);
va_copy(aq, ap);
ret = vsnprintf(test_buffer, bufsize, fmt, aq);
va_end(aq);
 
-   if (ret != elen) {
-   pr_warn("vsnprintf(buf, %d, \"%s\", ...) returned %d, expected 
%d\n",
+   KUNIT_EXPECT_EQ_MSG(kunittest, ret, elen,
+   "vsnprintf(buf, %d, \"%s\", ...) returned %d, expected 
%d\n",
bufsize, fmt, ret, elen);
-   return 1;
-   }
 
-   if (memchr_inv(alloced_buffer, FILL_CHAR, PAD_SIZE)) {
-   pr_warn("vsnprintf(buf, %d, \"%s\", ...) wrote before 
buffer\n", bufsize, fmt);
-   return 1;
-   }
+   KUNIT_EXPECT_EQ_MSG(kunittest, memchr_inv(alloced_buffer, FILL_CHAR, 
PAD_SIZE), NULL,
+   "vsnprintf(buf, %d, \"%s\", ...) wrote before buffer\n",
+   bufsize, fmt);
 
if (!bufsize) {
-   if (memchr_inv(test_buffer, FILL_CHAR, BUF_SIZE + PAD_SIZE)) {
-   pr_warn("vsnprintf(buf, 0, \"%s\", ...) wrote to 
buffer\n",
-   fmt);
-   return 1;
-   }
-   return 0;
+   KUNIT_EXPECT_FALSE_MSG(kunittest,
+   memchr_inv(test_buffer, FILL_CHAR, BUF_SIZE + PAD_SIZE),
+   "vsnprintf(buf, 0, \"%s\", ...) wrote to buffer\n", 
fmt);
+   return;
}
 
written = min(bufsize-1, elen);
-   if (test_buffer[written]) {
-   pr_warn("vsnprintf(buf, %d, \"%s\", ...) did not nul-terminate 
buffer\n",
+   KUNIT_EXPECT_FALSE_MSG(kunittest, test_buffer[written],
+   "vsnprintf(buf, %d, \"%s\", ...) did not nul-terminate 
buffer\n",
bufsize, fmt);
-   return 1;
-   }
 
-   if (memchr_inv(test_buffer + written + 1, FILL_CHAR, BUF_SIZE + 
PAD_SIZE - (written + 1))) {
-   pr_warn("vsnprintf(buf, %d, \"%s\", ...) 

Re: [PATCH] Makefile: Yes. Finally remove '-Wdeclaration-after-statement'

2020-08-16 Thread Joe Perches
On Mon, 2020-08-17 at 03:37 +, Michael Witten wrote:
> Matters of  style should  probably not be  enforced by  the build
> infrastructure; style is a matter for the maintainer to enforce:

I rather doubt style advice should be taken from someone who
right justifies fixed pitch block text.

cheers, Joe



Re: [PATCH] phylink: : fix function prototype kernel-doc warning

2020-08-16 Thread David Miller
From: Randy Dunlap 
Date: Sun, 16 Aug 2020 15:25:49 -0700

> Fix a kernel-doc warning for the pcs_config() function prototype:
> 
> ../include/linux/phylink.h:406: warning: Excess function parameter 
> 'permit_pause_to_mac' description in 'pcs_config'
> 
> Fixes: 7137e18f6f88 ("net: phylink: add struct phylink_pcs")
> Signed-off-by: Randy Dunlap 

There's no definition of this function anywhere.  Maybe just remove all of
this?


[PATCH RESEND 3/5] block: Add a new helper to attempt to merge a bio

2020-08-16 Thread Baolin Wang
There are lots of duplicated code when trying to merge a bio from
plug list and sw queue, we can introduce a new helper to attempt
to merge a bio, which can simplify the blk_mq_bio_list_merge()
and blk_attempt_plug_merge().

Signed-off-by: Baolin Wang 
---
 block/blk-merge.c| 47 +--
 block/blk-mq-sched.c | 22 --
 block/blk.h  |  9 +
 3 files changed, 42 insertions(+), 36 deletions(-)

diff --git a/block/blk-merge.c b/block/blk-merge.c
index 3619f2f..a8d1649 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -975,6 +975,33 @@ bool bio_attempt_discard_merge(struct request_queue *q, 
struct request *req,
return false;
 }
 
+enum bio_merge_status blk_attempt_bio_merge(struct request_queue *q,
+   struct request *rq,
+   struct bio *bio,
+   unsigned int nr_segs)
+{
+   bool merged = false;
+
+   if (!blk_rq_merge_ok(rq, bio))
+   return BIO_MERGE_NONE;
+
+   switch (blk_try_merge(rq, bio)) {
+   case ELEVATOR_BACK_MERGE:
+   merged = bio_attempt_back_merge(rq, bio, nr_segs);
+   break;
+   case ELEVATOR_FRONT_MERGE:
+   merged = bio_attempt_front_merge(rq, bio, nr_segs);
+   break;
+   case ELEVATOR_DISCARD_MERGE:
+   merged = bio_attempt_discard_merge(q, rq, bio);
+   break;
+   default:
+   return BIO_MERGE_NONE;
+   }
+
+   return merged ? BIO_MERGE_OK : BIO_MERGE_FAILED;
+}
+
 /**
  * blk_attempt_plug_merge - try to merge with %current's plugged list
  * @q: request_queue new bio is being queued at
@@ -1011,8 +1038,6 @@ bool blk_attempt_plug_merge(struct request_queue *q, 
struct bio *bio,
plug_list = &plug->mq_list;
 
list_for_each_entry_reverse(rq, plug_list, queuelist) {
-   bool merged = false;
-
if (rq->q == q && same_queue_rq) {
/*
 * Only blk-mq multiple hardware queues case checks the
@@ -1022,24 +1047,10 @@ bool blk_attempt_plug_merge(struct request_queue *q, 
struct bio *bio,
*same_queue_rq = rq;
}
 
-   if (rq->q != q || !blk_rq_merge_ok(rq, bio))
+   if (rq->q != q)
continue;
 
-   switch (blk_try_merge(rq, bio)) {
-   case ELEVATOR_BACK_MERGE:
-   merged = bio_attempt_back_merge(rq, bio, nr_segs);
-   break;
-   case ELEVATOR_FRONT_MERGE:
-   merged = bio_attempt_front_merge(rq, bio, nr_segs);
-   break;
-   case ELEVATOR_DISCARD_MERGE:
-   merged = bio_attempt_discard_merge(q, rq, bio);
-   break;
-   default:
-   break;
-   }
-
-   if (merged)
+   if (blk_attempt_bio_merge(q, rq, bio, nr_segs) == BIO_MERGE_OK)
return true;
}
 
diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index bf62b34..8e9bafe 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -391,31 +391,17 @@ bool blk_mq_bio_list_merge(struct request_queue *q, 
struct list_head *list,
 {
struct request *rq;
int checked = 8;
+   enum bio_merge_status merge;
 
list_for_each_entry_reverse(rq, list, queuelist) {
-   bool merged = false;
-
if (!checked--)
break;
 
-   if (!blk_rq_merge_ok(rq, bio))
+   merge = blk_attempt_bio_merge(q, rq, bio, nr_segs);
+   if (merge == BIO_MERGE_NONE)
continue;
 
-   switch (blk_try_merge(rq, bio)) {
-   case ELEVATOR_BACK_MERGE:
-   merged = bio_attempt_back_merge(rq, bio, nr_segs);
-   break;
-   case ELEVATOR_FRONT_MERGE:
-   merged = bio_attempt_front_merge(rq, bio, nr_segs);
-   break;
-   case ELEVATOR_DISCARD_MERGE:
-   merged = bio_attempt_discard_merge(q, rq, bio);
-   break;
-   default:
-   continue;
-   }
-
-   return merged;
+   return merge == BIO_MERGE_OK ? true: false;
}
 
return false;
diff --git a/block/blk.h b/block/blk.h
index 49e2928..a6c54e1 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -234,6 +234,15 @@ int blk_attempt_req_merge(struct request_queue *q, struct 
request *rq,
 bool blk_rq_merge_ok(struct request *rq, struct bio *bio);
 enum elv_merge blk_try_merge(struct request *rq, struct bio *bio);
 
+enum bio_merge_status {
+   BIO_MERGE_OK,
+   BIO_MERGE_NONE,
+   BIO_MERGE_FAILE

[PATCH RESEND 5/5] block: Remove __blk_mq_sched_bio_merge() helper

2020-08-16 Thread Baolin Wang
The blk_mq_sched_bio_merge() just wrap the __blk_mq_sched_bio_merge(), and
no other places will use __blk_mq_sched_bio_merge(). Thus we can combine
these 2 similar functions into one function.

Signed-off-by: Baolin Wang 
---
 block/blk-mq-sched.c |  5 -
 block/blk-mq-sched.h | 13 ++---
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index 1cc7919..ba34460 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -408,7 +408,7 @@ bool blk_mq_bio_list_merge(struct request_queue *q, struct 
list_head *list,
 }
 EXPORT_SYMBOL_GPL(blk_mq_bio_list_merge);
 
-bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
+bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
unsigned int nr_segs)
 {
struct elevator_queue *e = q->elevator;
@@ -417,6 +417,9 @@ bool __blk_mq_sched_bio_merge(struct request_queue *q, 
struct bio *bio,
bool ret = false;
enum hctx_type type;
 
+   if (blk_queue_nomerges(q) || !bio_mergeable(bio))
+   return false;
+
if (e && e->type->ops.bio_merge)
return e->type->ops.bio_merge(hctx, bio, nr_segs);
 
diff --git a/block/blk-mq-sched.h b/block/blk-mq-sched.h
index 126021f..65151de 100644
--- a/block/blk-mq-sched.h
+++ b/block/blk-mq-sched.h
@@ -13,8 +13,6 @@ void blk_mq_sched_free_hctx_data(struct request_queue *q,
 void blk_mq_sched_request_inserted(struct request *rq);
 bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio,
unsigned int nr_segs, struct request **merged_request);
-bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
-   unsigned int nr_segs);
 bool blk_mq_sched_try_insert_merge(struct request_queue *q, struct request 
*rq);
 void blk_mq_sched_mark_restart_hctx(struct blk_mq_hw_ctx *hctx);
 void blk_mq_sched_restart(struct blk_mq_hw_ctx *hctx);
@@ -31,15 +29,8 @@ void blk_mq_sched_insert_requests(struct blk_mq_hw_ctx *hctx,
 void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e);
 void blk_mq_sched_free_requests(struct request_queue *q);
 
-static inline bool
-blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
-   unsigned int nr_segs)
-{
-   if (blk_queue_nomerges(q) || !bio_mergeable(bio))
-   return false;
-
-   return __blk_mq_sched_bio_merge(q, bio, nr_segs);
-}
+bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
+   unsigned int nr_segs);
 
 static inline bool
 blk_mq_sched_allow_merge(struct request_queue *q, struct request *rq,
-- 
1.8.3.1



[PATCH RESEND 4/5] block: Remove blk_mq_attempt_merge() function

2020-08-16 Thread Baolin Wang
The small blk_mq_attempt_merge() function is only called by
__blk_mq_sched_bio_merge(), just open code it.

Signed-off-by: Baolin Wang 
---
 block/blk-mq-sched.c | 33 ++---
 1 file changed, 10 insertions(+), 23 deletions(-)

diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index 8e9bafe..1cc7919 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -408,28 +408,6 @@ bool blk_mq_bio_list_merge(struct request_queue *q, struct 
list_head *list,
 }
 EXPORT_SYMBOL_GPL(blk_mq_bio_list_merge);
 
-/*
- * Reverse check our software queue for entries that we could potentially
- * merge with. Currently includes a hand-wavy stop count of 8, to not spend
- * too much time checking for merges.
- */
-static bool blk_mq_attempt_merge(struct request_queue *q,
-struct blk_mq_hw_ctx *hctx,
-struct blk_mq_ctx *ctx, struct bio *bio,
-unsigned int nr_segs)
-{
-   enum hctx_type type = hctx->type;
-
-   lockdep_assert_held(&ctx->lock);
-
-   if (blk_mq_bio_list_merge(q, &ctx->rq_lists[type], bio, nr_segs)) {
-   ctx->rq_merged++;
-   return true;
-   }
-
-   return false;
-}
-
 bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
unsigned int nr_segs)
 {
@@ -447,7 +425,16 @@ bool __blk_mq_sched_bio_merge(struct request_queue *q, 
struct bio *bio,
!list_empty_careful(&ctx->rq_lists[type])) {
/* default per sw-queue merge */
spin_lock(&ctx->lock);
-   ret = blk_mq_attempt_merge(q, hctx, ctx, bio, nr_segs);
+   /*
+* Reverse check our software queue for entries that we could
+* potentially merge with. Currently includes a hand-wavy stop
+* count of 8, to not spend too much time checking for merges.
+*/
+   if (blk_mq_bio_list_merge(q, &ctx->rq_lists[type], bio, 
nr_segs)) {
+   ctx->rq_merged++;
+   ret = true;
+   }
+
spin_unlock(&ctx->lock);
}
 
-- 
1.8.3.1



[PATCH RESEND 1/5] block: Move bio merge related functions into blk-merge.c

2020-08-16 Thread Baolin Wang
It's better to move bio merge related functions into blk-merge.c,
which contains all merge related functions.

Signed-off-by: Baolin Wang 
---
 block/blk-core.c  | 156 -
 block/blk-merge.c | 157 ++
 2 files changed, 157 insertions(+), 156 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index d9d6326..ed79109 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -642,162 +642,6 @@ void blk_put_request(struct request *req)
 }
 EXPORT_SYMBOL(blk_put_request);
 
-static void blk_account_io_merge_bio(struct request *req)
-{
-   if (!blk_do_io_stat(req))
-   return;
-
-   part_stat_lock();
-   part_stat_inc(req->part, merges[op_stat_group(req_op(req))]);
-   part_stat_unlock();
-}
-
-bool bio_attempt_back_merge(struct request *req, struct bio *bio,
-   unsigned int nr_segs)
-{
-   const int ff = bio->bi_opf & REQ_FAILFAST_MASK;
-
-   if (!ll_back_merge_fn(req, bio, nr_segs))
-   return false;
-
-   trace_block_bio_backmerge(req->q, req, bio);
-   rq_qos_merge(req->q, req, bio);
-
-   if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff)
-   blk_rq_set_mixed_merge(req);
-
-   req->biotail->bi_next = bio;
-   req->biotail = bio;
-   req->__data_len += bio->bi_iter.bi_size;
-
-   bio_crypt_free_ctx(bio);
-
-   blk_account_io_merge_bio(req);
-   return true;
-}
-
-bool bio_attempt_front_merge(struct request *req, struct bio *bio,
-   unsigned int nr_segs)
-{
-   const int ff = bio->bi_opf & REQ_FAILFAST_MASK;
-
-   if (!ll_front_merge_fn(req, bio, nr_segs))
-   return false;
-
-   trace_block_bio_frontmerge(req->q, req, bio);
-   rq_qos_merge(req->q, req, bio);
-
-   if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff)
-   blk_rq_set_mixed_merge(req);
-
-   bio->bi_next = req->bio;
-   req->bio = bio;
-
-   req->__sector = bio->bi_iter.bi_sector;
-   req->__data_len += bio->bi_iter.bi_size;
-
-   bio_crypt_do_front_merge(req, bio);
-
-   blk_account_io_merge_bio(req);
-   return true;
-}
-
-bool bio_attempt_discard_merge(struct request_queue *q, struct request *req,
-   struct bio *bio)
-{
-   unsigned short segments = blk_rq_nr_discard_segments(req);
-
-   if (segments >= queue_max_discard_segments(q))
-   goto no_merge;
-   if (blk_rq_sectors(req) + bio_sectors(bio) >
-   blk_rq_get_max_sectors(req, blk_rq_pos(req)))
-   goto no_merge;
-
-   rq_qos_merge(q, req, bio);
-
-   req->biotail->bi_next = bio;
-   req->biotail = bio;
-   req->__data_len += bio->bi_iter.bi_size;
-   req->nr_phys_segments = segments + 1;
-
-   blk_account_io_merge_bio(req);
-   return true;
-no_merge:
-   req_set_nomerge(q, req);
-   return false;
-}
-
-/**
- * blk_attempt_plug_merge - try to merge with %current's plugged list
- * @q: request_queue new bio is being queued at
- * @bio: new bio being queued
- * @nr_segs: number of segments in @bio
- * @same_queue_rq: pointer to &struct request that gets filled in when
- * another request associated with @q is found on the plug list
- * (optional, may be %NULL)
- *
- * Determine whether @bio being queued on @q can be merged with a request
- * on %current's plugged list.  Returns %true if merge was successful,
- * otherwise %false.
- *
- * Plugging coalesces IOs from the same issuer for the same purpose without
- * going through @q->queue_lock.  As such it's more of an issuing mechanism
- * than scheduling, and the request, while may have elvpriv data, is not
- * added on the elevator at this point.  In addition, we don't have
- * reliable access to the elevator outside queue lock.  Only check basic
- * merging parameters without querying the elevator.
- *
- * Caller must ensure !blk_queue_nomerges(q) beforehand.
- */
-bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
-   unsigned int nr_segs, struct request **same_queue_rq)
-{
-   struct blk_plug *plug;
-   struct request *rq;
-   struct list_head *plug_list;
-
-   plug = blk_mq_plug(q, bio);
-   if (!plug)
-   return false;
-
-   plug_list = &plug->mq_list;
-
-   list_for_each_entry_reverse(rq, plug_list, queuelist) {
-   bool merged = false;
-
-   if (rq->q == q && same_queue_rq) {
-   /*
-* Only blk-mq multiple hardware queues case checks the
-* rq in the same queue, there should be only one such
-* rq in a queue
-**/
-   *same_queue_rq = rq;
-   }
-
-   if (rq->q != q || !blk_rq_merge_ok(rq, bio))
-   continue;
-
-   switch (blk_try_merge(rq, bio)) {
-   case

[PATCH RESEND 2/5] block: Remove redundant blk_mq_sched_allow_merge() validation

2020-08-16 Thread Baolin Wang
Only software queue and kyber IO scheduler will call blk_mq_bio_list_merge()
to merge a bio, and kyber IO scheduler did not implement the ops->allow_merge().
Thus we can remove the redundant blk_mq_sched_allow_merge() in
blk_mq_bio_list_merge() function.

Signed-off-by: Baolin Wang 
---
 block/blk-mq-sched.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index a19cdf1..bf62b34 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -403,14 +403,10 @@ bool blk_mq_bio_list_merge(struct request_queue *q, 
struct list_head *list,
 
switch (blk_try_merge(rq, bio)) {
case ELEVATOR_BACK_MERGE:
-   if (blk_mq_sched_allow_merge(q, rq, bio))
-   merged = bio_attempt_back_merge(rq, bio,
-   nr_segs);
+   merged = bio_attempt_back_merge(rq, bio, nr_segs);
break;
case ELEVATOR_FRONT_MERGE:
-   if (blk_mq_sched_allow_merge(q, rq, bio))
-   merged = bio_attempt_front_merge(rq, bio,
-   nr_segs);
+   merged = bio_attempt_front_merge(rq, bio, nr_segs);
break;
case ELEVATOR_DISCARD_MERGE:
merged = bio_attempt_discard_merge(q, rq, bio);
-- 
1.8.3.1



[PATCH RESEND 0/5] Some clean-ups for bio merge

2020-08-16 Thread Baolin Wang
Hi,

There are some duplicated code when trying to merge bio from pluged list
and software queue, thus this patch set did some clean-ups when merging
a bio. Any comments are welcome. Thanks.

Baolin Wang (5):
  block: Move bio merge related functions into blk-merge.c
  block: Remove redundant blk_mq_sched_allow_merge() validation
  block: Add a new helper to attempt to merge a bio
  block: Remove blk_mq_attempt_merge() function
  block: Remove __blk_mq_sched_bio_merge() helper

 block/blk-core.c | 156 ---
 block/blk-merge.c| 168 +++
 block/blk-mq-sched.c |  64 ++--
 block/blk-mq-sched.h |  13 +---
 block/blk.h  |   9 +++
 5 files changed, 197 insertions(+), 213 deletions(-)

-- 
1.8.3.1



[PATCH] arm64: dts: qcom: sc7180: Fix the LLCC base register size

2020-08-16 Thread Sai Prakash Ranjan
There is only one LLCC logical bank on SC7180 SoC of size
0x5(320KB) not 2MB, so correct the size and fix copy
paste mistake from SDM845 which had 4 logical banks.

Fixes: 7cee5c742899 ("arm64: dts: qcom: sc7180: Fix node order")
Fixes: c831fa26 ("arm64: dts: qcom: sc7180: Add Last level cache controller 
node")
Signed-off-by: Sai Prakash Ranjan 
---
 arch/arm64/boot/dts/qcom/sc7180.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/sc7180.dtsi 
b/arch/arm64/boot/dts/qcom/sc7180.dtsi
index d46b3833e52f..e875f6c3b663 100644
--- a/arch/arm64/boot/dts/qcom/sc7180.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7180.dtsi
@@ -2618,7 +2618,7 @@ dc_noc: interconnect@916 {
 
system-cache-controller@920 {
compatible = "qcom,sc7180-llcc";
-   reg = <0 0x0920 0 0x20>, <0 0x0960 0 
0x5>;
+   reg = <0 0x0920 0 0x5>, <0 0x0960 0 
0x5>;
reg-names = "llcc_base", "llcc_broadcast_base";
interrupts = ;
};
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



Re: [PATCH v6 2/2] soc: mediatek: add mt6779 devapc driver

2020-08-16 Thread Neal Liu
Hi Chun-Kuang,

On Sat, 2020-08-15 at 11:03 +0800, Chun-Kuang Hu wrote:
> Hi, Neal:
> 
> Neal Liu  於 2020年8月13日 週四 上午11:33寫道:
> >
> > MediaTek bus fabric provides TrustZone security support and data
> > protection to prevent slaves from being accessed by unexpected
> > masters.
> > The security violation is logged and sent to the processor for
> > further analysis or countermeasures.
> >
> > Any occurrence of security violation would raise an interrupt, and
> > it will be handled by mtk-devapc driver. The violation
> > information is printed in order to find the murderer.
> >
> > Signed-off-by: Neal Liu 
> > ---
> 
> [snip]
> 
> > +/*
> > + * devapc_violation_irq - the devapc Interrupt Service Routine (ISR) will 
> > dump
> > + *violation information including which master 
> > violates
> > + *access slave.
> > + */
> > +static irqreturn_t devapc_violation_irq(int irq_number,
> > +   struct mtk_devapc_context *ctx)
> > +{
> > +   /*
> > +* Mask slave's irq before clearing vio status.
> > +* Must do it to avoid nested interrupt and prevent
> > +* unexpected behavior.
> > +*/
> > +   mask_module_irq(ctx, true);
> 
> I still don't understand why nested interrupt happen. If two CPU
> process different devapc interrupt at the same time, mask interrupt
> could not prevent these two CPU to sync vio dbg at the same time. As I
> know, in ARM CPU, only CPU0 process irq handler, and all devapc
> interrupt has the same priority, so why nested interrupt happen? Could
> you explain more detail about how nested interrupt happen?

If there is another violation happened before previous violation is
fully handled, nested interrupt would happen.

Let's me take an example:
vio A happen
enter A ISR
... vio B happen
finish A ISRenter B ISR
...
finish B ISR

We mask all module's irq to avoid nested interrupt.

> 
> > +
> > +   while (devapc_sync_vio_dbg(ctx))
> > +   devapc_extract_vio_dbg(ctx);
> > +
> > +   /*
> > +* Ensure that violation info are written
> > +* before further operations
> > +*/
> > +   smp_mb();
> > +
> > +   clear_vio_status(ctx);
> > +   mask_module_irq(ctx, false);
> > +
> > +   return IRQ_HANDLED;
> > +}
> > +
> 
> [snip]
> 
> > +
> > +static int mtk_devapc_remove(struct platform_device *pdev)
> > +{
> > +   struct mtk_devapc_context *ctx = platform_get_drvdata(pdev);
> > +
> > +   stop_devapc(ctx);
> > +
> > +   if (ctx->infra_clk)
> 
> This always true.

Does it mean that remove function would be called only if probe function
is returned successfully?
Is there any chance this function would be called directly?

> 
> Regards,
> Chun-Kuang.
> 
> > +   clk_disable_unprepare(ctx->infra_clk);
> > +
> > +   return 0;
> > +}
> > +
> > +static struct platform_driver mtk_devapc_driver = {
> > +   .probe = mtk_devapc_probe,
> > +   .remove = mtk_devapc_remove,
> > +   .driver = {
> > +   .name = KBUILD_MODNAME,
> > +   .of_match_table = mtk_devapc_dt_match,
> > +   },
> > +};
> > +
> > +module_platform_driver(mtk_devapc_driver);
> > +
> > +MODULE_DESCRIPTION("Mediatek Device APC Driver");
> > +MODULE_AUTHOR("Neal Liu ");
> > +MODULE_LICENSE("GPL");
> > --
> > 1.7.9.5
> > ___
> > Linux-mediatek mailing list
> > linux-media...@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-mediatek



Re: [PATCH] net: handle the return value of pskb_carve_frag_list() correctly

2020-08-16 Thread David Miller
From: linmiaohe 
Date: Mon, 17 Aug 2020 02:27:23 +

> David Miller  wrote:
>>> +   /* split line is in frag list */
>>> +   if (k == 0 && pskb_carve_frag_list(skb, shinfo, off - pos, gfp_mask)) {
>>> +   /* skb_frag_unref() is not needed here as shinfo->nr_frags = 0. 
>>> */
>>> +   if (skb_has_frag_list(skb))
>>> +   kfree_skb_list(skb_shinfo(skb)->frag_list);
>>> +   kfree(data);
>>> +   return -ENOMEM;
>>
>>On error, the caller is going to kfree_skb(skb) which will take care of the 
>>frag list.
>>
> 
> I'am sorry for my careless. The caller will take care of the frag list and 
> kfree(data) is enough here.
> Many thanks for review, will send v2 soon.

Actually, reading this again, what about the skb_clone_fraglist() done a few
lines up?  Who will release that reference to the fraglist items?

Maybe the kfree_skb_list() is necessary after all?


[PATCH 7/7] MIPS: KVM: Don't use htimer when INTIMER is disabled

2020-08-16 Thread Jiaxun Yang
When INTIMER is disabled by host, the GT compare interrupt
will be ignored.

Signed-off-by: Jiaxun Yang 
---
 arch/mips/kvm/vz.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/mips/kvm/vz.c b/arch/mips/kvm/vz.c
index 9d03bd0a604a..1d2140f7461a 100644
--- a/arch/mips/kvm/vz.c
+++ b/arch/mips/kvm/vz.c
@@ -341,6 +341,12 @@ static bool kvm_vz_should_use_htimer(struct kvm_vcpu *vcpu)
if (kvm_mips_count_disabled(vcpu))
return false;
 
+   if (cpu_has_extimer) {
+   /* Guest htimer compare interrupt will be ignored if INTIMER is 
disabled */
+   if (!(read_c0_config6() & LOONGSON_CONF6_INTIMER))
+   return false;
+   }
+
/* Chosen frequency must match real frequency */
if (mips_hpt_frequency != vcpu->arch.count_hz)
return false;
-- 
2.28.0.rc1



[PATCH 6/7] MIPS: cevt-r4k: Enable intimer for Loongson CPUs with extimer

2020-08-16 Thread Jiaxun Yang
Loongson64C and Loongson64G have extimer feature, which is sharing
Cause.TI with intimer (which is cevt-r4k).

To ensure the cevt-r4k's usability, we need to add a callback for
clock device to ensure intimer is enabled when cevt-r4k is enabled.

Signed-off-by: Jiaxun Yang 
---
 arch/mips/include/asm/cpu-features.h |  4 
 arch/mips/include/asm/cpu.h  |  1 +
 arch/mips/kernel/cevt-r4k.c  | 25 +
 arch/mips/kernel/cpu-probe.c |  6 +-
 4 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/cpu-features.h 
b/arch/mips/include/asm/cpu-features.h
index 78cf7e300f12..aec458eee2a5 100644
--- a/arch/mips/include/asm/cpu-features.h
+++ b/arch/mips/include/asm/cpu-features.h
@@ -576,6 +576,10 @@
 # define cpu_has_gsexcex   __opt(MIPS_CPU_GSEXCEX)
 #endif
 
+#ifndef cpu_has_extimer
+# define cpu_has_extimer   __opt(MIPS_CPU_EXTIMER)
+#endif
+
 #ifdef CONFIG_SMP
 /*
  * Some systems share FTLB RAMs between threads within a core (siblings in
diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h
index 388a82f28a87..854e1b44254b 100644
--- a/arch/mips/include/asm/cpu.h
+++ b/arch/mips/include/asm/cpu.h
@@ -429,6 +429,7 @@ enum cpu_type_enum {
 #define MIPS_CPU_MAC_2008_ONLY BIT_ULL(60) /* CPU Only support MAC2008 
Fused multiply-add instruction */
 #define MIPS_CPU_FTLBPAREX BIT_ULL(61) /* CPU has FTLB parity 
exception */
 #define MIPS_CPU_GSEXCEX   BIT_ULL(62) /* CPU has GSExc exception */
+#define MIPS_CPU_EXTIMER   BIT_ULL(63) /* CPU has External Timer 
(Loongson) */
 
 /*
  * CPU ASE encodings
diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
index d396b1011fee..a6e56e9d4e70 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -15,6 +15,8 @@
 
 #include 
 #include 
+#include 
+#include 
 
 static int mips_next_event(unsigned long delta,
   struct clock_event_device *evt)
@@ -302,6 +304,24 @@ core_initcall(r4k_register_cpufreq_notifier);
 
 #endif /* !CONFIG_CPU_FREQ */
 
+#ifdef CONFIG_CPU_LOONGSON64
+static int c0_compare_int_enable(struct clock_event_device *cd)
+{
+   if (cpu_has_extimer)
+   set_c0_config6(LOONGSON_CONF6_INTIMER);
+
+   return 0;
+}
+
+static int c0_compare_int_disable(struct clock_event_device *cd)
+{
+   if (cpu_has_extimer)
+   clear_c0_config6(LOONGSON_CONF6_INTIMER);
+
+   return 0;
+}
+#endif
+
 int r4k_clockevent_percpu_init(int cpu)
 {
struct clock_event_device *cd;
@@ -330,6 +350,11 @@ int r4k_clockevent_percpu_init(int cpu)
cd->set_next_event  = mips_next_event;
cd->event_handler   = mips_event_handler;
 
+#ifdef CONFIG_CPU_LOONGSON64
+   cd->set_state_oneshot = c0_compare_int_enable;
+   cd->set_state_shutdown = c0_compare_int_disable;
+#endif
+
clockevents_config_and_register(cd, mips_hpt_frequency, min_delta, 
0x7fff);
 
return 0;
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index e2955f1f6316..f41e8d4f6d84 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -2030,6 +2030,9 @@ static inline void decode_cpucfg(struct cpuinfo_mips *c)
if (cfg2 & LOONGSON_CFG2_LEXT2)
c->ases |= MIPS_ASE_LOONGSON_EXT2;
 
+   if (cfg2 & LOONGSON_CFG2_LLFTP)
+   c->options |= MIPS_CPU_EXTIMER;
+
if (cfg2 & LOONGSON_CFG2_LSPW) {
c->options |= MIPS_CPU_LDPTE;
c->guest.options |= MIPS_CPU_LDPTE;
@@ -2088,7 +2091,8 @@ static inline void cpu_probe_loongson(struct cpuinfo_mips 
*c, unsigned int cpu)
 * Also some early Loongson-3A2000 had wrong TLB type in Config
 * register, we correct it here.
 */
-   c->options |= MIPS_CPU_FTLB | MIPS_CPU_TLBINV | MIPS_CPU_LDPTE;
+   c->options |= MIPS_CPU_FTLB | MIPS_CPU_TLBINV | MIPS_CPU_LDPTE |
+ MIPS_CPU_EXTIMER;
c->writecombine = _CACHE_UNCACHED_ACCELERATED;
c->ases |= (MIPS_ASE_LOONGSON_MMI | MIPS_ASE_LOONGSON_CAM |
MIPS_ASE_LOONGSON_EXT | MIPS_ASE_LOONGSON_EXT2);
-- 
2.28.0.rc1



[PATCH 5/7] MIPS: cevt-r4k: Don't handle IRQ if clockevent is not enabled

2020-08-16 Thread Jiaxun Yang
Some platforms may have shared Cause.TI, bailing out in IRQ handler
when clock event is not enabled can give another clock device a chance.

Signed-off-by: Jiaxun Yang 
---
 arch/mips/kernel/cevt-r4k.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
index f0c52d751d0a..d396b1011fee 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -142,6 +142,15 @@ irqreturn_t c0_compare_interrupt(int irq, void *dev_id)
if (handle_perf_irq(r2))
return IRQ_HANDLED;
 
+   cd = &per_cpu(mips_clockevent_device, cpu);
+   /*
+* If the clockevent have not enabled, then no need to check the rest.
+* Some platforms may have shared Cause.TI, bailing out here can
+* give another clock device a chance.
+*/
+   if (clockevent_state_detached(cd) || clockevent_state_shutdown(cd))
+   return IRQ_NONE;
+
/*
 * The same applies to performance counter interrupts.  But with the
 * above we now know that the reason we got here must be a timer
@@ -150,7 +159,6 @@ irqreturn_t c0_compare_interrupt(int irq, void *dev_id)
if (!r2 || (read_c0_cause() & CAUSEF_TI)) {
/* Clear Count/Compare Interrupt */
write_c0_compare(read_c0_compare());
-   cd = &per_cpu(mips_clockevent_device, cpu);
cd->event_handler(cd);
 
return IRQ_HANDLED;
-- 
2.28.0.rc1



[PATCH 4/7] MIPS: Loongson64: Remove custom count sync procudure

2020-08-16 Thread Jiaxun Yang
Now we have hotplug aware reliable sync-r4k, we can simply use
that instead of our IPI based implementation.

Signed-off-by: Jiaxun Yang 
---
 arch/mips/include/asm/smp.h |  1 -
 arch/mips/loongson64/smp.c  | 32 ++--
 2 files changed, 2 insertions(+), 31 deletions(-)

diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h
index 5d9ff61004ca..2300cc0bba34 100644
--- a/arch/mips/include/asm/smp.h
+++ b/arch/mips/include/asm/smp.h
@@ -52,7 +52,6 @@ extern int __cpu_logical_map[NR_CPUS];
 #define SMP_CALL_FUNCTION  0x2
 /* Octeon - Tell another core to flush its icache */
 #define SMP_ICACHE_FLUSH   0x4
-#define SMP_ASK_C0COUNT0x8
 
 /* Mask of CPUs which are currently definitely operating coherently */
 extern cpumask_t cpu_coherent_mask;
diff --git a/arch/mips/loongson64/smp.c b/arch/mips/loongson64/smp.c
index e744e1bee49e..d6a3a7c3d1b2 100644
--- a/arch/mips/loongson64/smp.c
+++ b/arch/mips/loongson64/smp.c
@@ -32,7 +32,6 @@ static void *ipi_clear0_regs[16];
 static void *ipi_status0_regs[16];
 static void *ipi_en0_regs[16];
 static void *ipi_mailbox_buf[16];
-static uint32_t core0_c0count[NR_CPUS];
 
 /* read a 32bit value from ipi register */
 #define loongson3_ipi_read32(addr) readl(addr)
@@ -307,8 +306,8 @@ loongson3_send_ipi_mask(const struct cpumask *mask, 
unsigned int action)
 
 static irqreturn_t loongson3_ipi_interrupt(int irq, void *dev_id)
 {
-   int i, cpu = smp_processor_id();
-   unsigned int action, c0count;
+   int cpu = smp_processor_id();
+   unsigned int action;
 
action = ipi_read_clear(cpu);
 
@@ -321,15 +320,6 @@ static irqreturn_t loongson3_ipi_interrupt(int irq, void 
*dev_id)
irq_exit();
}
 
-   if (action & SMP_ASK_C0COUNT) {
-   BUG_ON(cpu != 0);
-   c0count = read_c0_count();
-   c0count = c0count ? c0count : 1;
-   for (i = 1; i < nr_cpu_ids; i++)
-   core0_c0count[i] = c0count;
-   __wbflush(); /* Let others see the result ASAP */
-   }
-
return IRQ_HANDLED;
 }
 
@@ -340,7 +330,6 @@ static irqreturn_t loongson3_ipi_interrupt(int irq, void 
*dev_id)
 static void loongson3_init_secondary(void)
 {
int i;
-   uint32_t initcount;
unsigned int cpu = smp_processor_id();
unsigned int imask = STATUSF_IP7 | STATUSF_IP6 |
 STATUSF_IP3 | STATUSF_IP2;
@@ -356,23 +345,6 @@ static void loongson3_init_secondary(void)
 cpu_logical_map(cpu) % loongson_sysconf.cores_per_package);
cpu_data[cpu].package =
cpu_logical_map(cpu) / loongson_sysconf.cores_per_package;
-
-   i = 0;
-   core0_c0count[cpu] = 0;
-   loongson3_send_ipi_single(0, SMP_ASK_C0COUNT);
-   while (!core0_c0count[cpu]) {
-   i++;
-   cpu_relax();
-   }
-
-   if (i > MAX_LOOPS)
-   i = MAX_LOOPS;
-   if (cpu_data[cpu].package)
-   initcount = core0_c0count[cpu] + i;
-   else /* Local access is faster for loops */
-   initcount = core0_c0count[cpu] + i/2;
-
-   write_c0_count(initcount);
 }
 
 static void loongson3_smp_finish(void)
-- 
2.28.0.rc1



[PATCH 2/7] MIPS: time: Use CPUHUP to handle r4k timer

2020-08-16 Thread Jiaxun Yang
There is no need to hijack initialization procudre to take care of
r4k timer we have CPUHP framework to deal with the CPU plug sequence.

Signed-off-by: Jiaxun Yang 
---
 arch/mips/include/asm/time.h | 28 +++-
 arch/mips/kernel/cevt-r4k.c  | 30 ++
 arch/mips/kernel/smp.c   |  3 ---
 arch/mips/kernel/time.c  | 22 --
 include/linux/cpuhotplug.h   |  1 +
 5 files changed, 58 insertions(+), 26 deletions(-)

diff --git a/arch/mips/include/asm/time.h b/arch/mips/include/asm/time.h
index e855a3611d92..d00a5b05a420 100644
--- a/arch/mips/include/asm/time.h
+++ b/arch/mips/include/asm/time.h
@@ -39,30 +39,32 @@ extern int __weak get_c0_perfcount_int(void);
  * Initialize the calling CPU's compare interrupt as clockevent device
  */
 extern unsigned int get_c0_compare_int(void);
-extern int r4k_clockevent_init(void);
 
-static inline int mips_clockevent_init(void)
-{
 #ifdef CONFIG_CEVT_R4K
-   return r4k_clockevent_init();
+extern int r4k_clockevent_init(void);
+extern int r4k_clockevent_percpu_init(int cpu);
 #else
-   return -ENXIO;
-#endif
+static inline int r4k_clockevent_init(void)
+{
+   return -ENODEV;
+}
+static inline int r4k_clockevent_percpu_init(int cpu)
+{
+   return -ENODEV;
 }
+#endif
 
 /*
  * Initialize the count register as a clocksource
  */
-extern int init_r4k_clocksource(void);
-
-static inline int init_mips_clocksource(void)
-{
 #ifdef CONFIG_CSRC_R4K
-   return init_r4k_clocksource();
+extern int init_r4k_clocksource(void);
 #else
-   return 0;
-#endif
+static inline int init_r4k_clocksource(void)
+{
+   return -ENODEV;
 }
+#endif
 
 static inline void clockevent_set_clock(struct clock_event_device *cd,
unsigned int clock)
diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
index 995ad9e69ded..f0c52d751d0a 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -294,10 +294,8 @@ core_initcall(r4k_register_cpufreq_notifier);
 
 #endif /* !CONFIG_CPU_FREQ */
 
-int r4k_clockevent_init(void)
+int r4k_clockevent_percpu_init(int cpu)
 {
-   unsigned long flags = IRQF_PERCPU | IRQF_TIMER | IRQF_SHARED;
-   unsigned int cpu = smp_processor_id();
struct clock_event_device *cd;
unsigned int irq, min_delta;
 
@@ -307,11 +305,6 @@ int r4k_clockevent_init(void)
if (!c0_compare_int_usable())
return -ENXIO;
 
-   /*
-* With vectored interrupts things are getting platform specific.
-* get_c0_compare_int is a hook to allow a platform to return the
-* interrupt number of its liking.
-*/
irq = get_c0_compare_int();
 
cd = &per_cpu(mips_clockevent_device, cpu);
@@ -331,9 +324,30 @@ int r4k_clockevent_init(void)
 
clockevents_config_and_register(cd, mips_hpt_frequency, min_delta, 
0x7fff);
 
+   return 0;
+}
+
+int r4k_clockevent_init(void)
+{
+   int ret;
+   unsigned int irq;
+   unsigned long flags = IRQF_PERCPU | IRQF_TIMER | IRQF_SHARED;
+
+   ret = r4k_clockevent_percpu_init(0);
+   if (ret)
+   return ret;
+
+
if (cp0_timer_irq_installed)
return 0;
 
+   /*
+* With vectored interrupts things are getting platform specific.
+* get_c0_compare_int is a hook to allow a platform to return the
+* interrupt number of its liking.
+*/
+   irq = get_c0_compare_int();
+
cp0_timer_irq_installed = 1;
 
if (request_irq(irq, c0_compare_interrupt, flags, "timer",
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index ead9ac883241..0ca4f7cf6402 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -337,7 +337,6 @@ asmlinkage void start_secondary(void)
 
cpu_probe();
per_cpu_trap_init(false);
-   mips_clockevent_init();
mp_ops->init_secondary();
cpu_report();
maar_init();
@@ -358,8 +357,6 @@ asmlinkage void start_secondary(void)
/* Notify boot CPU that we're starting & ready to sync counters */
complete(&cpu_starting);
 
-   synchronise_count_slave(cpu);
-
/* The CPU is running and counters synchronised, now mark it online */
set_cpu_online(cpu, true);
 
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index caa01457dce6..9b16e60aaa30 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -8,6 +8,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -24,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #ifdef CONFIG_CPU_FREQ
@@ -155,6 +157,16 @@ static __init int cpu_has_mfc0_count_bug(void)
return 0;
 }
 
+#if defined(CONFIG_CEVT_R4K) || defined(CONFIG_CSRC_R4K)
+static int mips_r4k_timer_starting_cpu(unsigned int cpu)
+{
+   synchronise_count_slave(cpu);
+   r4k_clockevent_percpu_init(cpu);
+
+   return 0;
+}
+#endif

[PATCH 3/7] MIPS: Kconfig: Always select SYNC_R4K if both SMP and r4k timer is enabled

2020-08-16 Thread Jiaxun Yang
Now all platforms are sharing sync-r4k procdure, there is no need to let
platform to select it.

Signed-off-by: Jiaxun Yang 
---
 arch/mips/Kconfig | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 880680c0df31..7674f4379d39 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -234,7 +234,6 @@ config BMIPS_GENERIC
select USE_OF
select CEVT_R4K
select CSRC_R4K
-   select SYNC_R4K
select COMMON_CLK
select BCM6345_L1_IRQ
select BCM7038_L1_IRQ
@@ -291,7 +290,6 @@ config BCM63XX
select BOOT_RAW
select CEVT_R4K
select CSRC_R4K
-   select SYNC_R4K
select DMA_NONCOHERENT
select IRQ_MIPS_CPU
select SYS_SUPPORTS_32BIT_KERNEL
@@ -726,7 +724,6 @@ config SGI_IP30
select BOOT_ELF64
select CEVT_R4K
select CSRC_R4K
-   select SYNC_R4K if SMP
select ZONE_DMA32
select HAVE_PCI
select IRQ_MIPS_CPU
@@ -979,7 +976,6 @@ config NLM_XLR_BOARD
select CSRC_R4K
select IRQ_MIPS_CPU
select ZONE_DMA32 if 64BIT
-   select SYNC_R4K
select SYS_HAS_EARLY_PRINTK
select SYS_SUPPORTS_ZBOOT
select SYS_SUPPORTS_ZBOOT_UART16550
@@ -1006,7 +1002,6 @@ config NLM_XLP_BOARD
select CSRC_R4K
select IRQ_MIPS_CPU
select ZONE_DMA32 if 64BIT
-   select SYNC_R4K
select SYS_HAS_EARLY_PRINTK
select USE_OF
select SYS_SUPPORTS_ZBOOT
@@ -1076,6 +1071,7 @@ config CEVT_GT641XX
bool
 
 config CEVT_R4K
+   select SYNC_R4K if SMP
bool
 
 config CEVT_SB1250
@@ -1091,6 +1087,7 @@ config CSRC_IOASIC
bool
 
 config CSRC_R4K
+   select SYNC_R4K if SMP
select CLOCKSOURCE_WATCHDOG if CPU_FREQ
bool
 
@@ -2361,7 +2358,6 @@ config MIPS_MT_SMP
depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MIPSR6 && !CPU_MICROMIPS
select CPU_MIPSR2_IRQ_VI
select CPU_MIPSR2_IRQ_EI
-   select SYNC_R4K
select MIPS_MT
select SMP
select SMP_UP
@@ -2465,7 +2461,6 @@ config MIPS_CMP
bool "MIPS CMP framework support (DEPRECATED)"
depends on SYS_SUPPORTS_MIPS_CMP && !CPU_MIPSR6
select SMP
-   select SYNC_R4K
select SYS_SUPPORTS_SMP
select WEAK_ORDERING
default n
@@ -2483,7 +2478,6 @@ config MIPS_CPS
select MIPS_CM
select MIPS_CPS_PM if HOTPLUG_CPU
select SMP
-   select SYNC_R4K if (CEVT_R4K || CSRC_R4K)
select SYS_SUPPORTS_HOTPLUG_CPU
select SYS_SUPPORTS_SCHED_SMT if CPU_MIPSR6
select SYS_SUPPORTS_SMP
-- 
2.28.0.rc1



[PATCH 1/7] MIPS: sync-r4k: Rework to be many cores firendly

2020-08-16 Thread Jiaxun Yang
The original sync-r4k did a good job on reducing jitter by determine
the "next time value", but it has a limitation that when we have lots
of cores, the timewrap on CPU0 will become unaccpetable. That will also
happen when CPU Hotplug is enabled and the counter needs to be synchronised
at every plug event.

Here we reworked the whole procdure. Now the synchronise event on CPU0
is triggered by smp call function, and we won't touch the count on CPU0
at all.

Signed-off-by: Jiaxun Yang 
---
 arch/mips/include/asm/r4k-timer.h |   5 --
 arch/mips/kernel/smp.c|   2 -
 arch/mips/kernel/sync-r4k.c   | 143 +-
 3 files changed, 61 insertions(+), 89 deletions(-)

diff --git a/arch/mips/include/asm/r4k-timer.h 
b/arch/mips/include/asm/r4k-timer.h
index afe9e0e03fe9..2789d2fc5e23 100644
--- a/arch/mips/include/asm/r4k-timer.h
+++ b/arch/mips/include/asm/r4k-timer.h
@@ -12,15 +12,10 @@
 
 #ifdef CONFIG_SYNC_R4K
 
-extern void synchronise_count_master(int cpu);
 extern void synchronise_count_slave(int cpu);
 
 #else
 
-static inline void synchronise_count_master(int cpu)
-{
-}
-
 static inline void synchronise_count_slave(int cpu)
 {
 }
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 48d84d5fcc36..ead9ac883241 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -444,8 +444,6 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
return -EIO;
}
 
-   synchronise_count_master(cpu);
-
/* Wait for CPU to finish startup & mark itself online before return */
wait_for_completion(&cpu_running);
return 0;
diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
index abdd7aaa3311..c3e36d6d57fa 100644
--- a/arch/mips/kernel/sync-r4k.c
+++ b/arch/mips/kernel/sync-r4k.c
@@ -1,122 +1,101 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
  * Count register synchronisation.
- *
- * All CPUs will have their count registers synchronised to the CPU0 next time
- * value. This can cause a small timewarp for CPU0. All other CPU's should
- * not have done anything significant (but they may have had interrupts
- * enabled briefly - prom_smp_finish() should not be responsible for enabling
- * interrupts...)
  */
 
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
 
-static unsigned int initcount = 0;
-static atomic_t count_count_start = ATOMIC_INIT(0);
-static atomic_t count_count_stop = ATOMIC_INIT(0);
+#define STAGE_START0
+#define STAGE_MASTER_READY 1
+#define STAGE_SLAVE_SYNCED 2
 
-#define COUNTON 100
-#define NR_LOOPS 3
+static unsigned int cur_count;
+static unsigned int fini_count;
+static atomic_t sync_stage = ATOMIC_INIT(0);
+static DEFINE_RAW_SPINLOCK(sync_r4k_lock);
 
-void synchronise_count_master(int cpu)
+#define MAX_LOOPS  1000
+
+void synchronise_count_master(void *unused)
 {
-   int i;
unsigned long flags;
+   long delta;
+   int i;
 
-   pr_info("Synchronize counters for CPU %u: ", cpu);
+   if (atomic_read(&sync_stage) != STAGE_START)
+   BUG();
 
local_irq_save(flags);
 
-   /*
-* We loop a few times to get a primed instruction cache,
-* then the last pass is more or less synchronised and
-* the master and slaves each set their cycle counters to a known
-* value all at once. This reduces the chance of having random offsets
-* between the processors, and guarantees that the maximum
-* delay between the cycle counters is never bigger than
-* the latency of information-passing (cachelines) between
-* two CPUs.
-*/
-
-   for (i = 0; i < NR_LOOPS; i++) {
-   /* slaves loop on '!= 2' */
-   while (atomic_read(&count_count_start) != 1)
-   mb();
-   atomic_set(&count_count_stop, 0);
-   smp_wmb();
+   cur_count = read_c0_count();
+   smp_wmb();
+   atomic_inc(&sync_stage); /* inc to STAGE_MASTER_READY */
 
-   /* Let the slave writes its count register */
-   atomic_inc(&count_count_start);
-
-   /* Count will be initialised to current timer */
-   if (i == 1)
-   initcount = read_c0_count();
-
-   /*
-* Everyone initialises count in the last loop:
-*/
-   if (i == NR_LOOPS-1)
-   write_c0_count(initcount);
-
-   /*
-* Wait for slave to leave the synchronization point:
-*/
-   while (atomic_read(&count_count_stop) != 1)
-   mb();
-   atomic_set(&count_count_start, 0);
+   for (i = 0; i < MAX_LOOPS; i++) {
+   cur_count = read_c0_count();
smp_wmb();
-   atomic_inc(&count_count_stop);
+   if (atomic_read(&sync_stage) == STAGE_SLAV

[PATCH 0/7] R4000 clock enhancements for Loongson

2020-08-16 Thread Jiaxun Yang
Jiaxun Yang (7):
  MIPS: sync-r4k: Rework to be many cores firendly
  MIPS: time: Use CPUHUP to handle r4k timer
  MIPS: Kconfig: Always select SYNC_R4K if both SMP and r4k timer is
enabled
  MIPS: Loongson64: Remove custom count sync procudure
  MIPS: cevt-r4k: Don't handle IRQ if clockevent is not enabled
  MIPS: cevt-r4k: Enable intimer for Loongson CPUs with extimer
  MIPS: KVM: Don't use htimer when INTIMER is disabled

 arch/mips/Kconfig|  10 +-
 arch/mips/include/asm/cpu-features.h |   4 +
 arch/mips/include/asm/cpu.h  |   1 +
 arch/mips/include/asm/r4k-timer.h|   5 -
 arch/mips/include/asm/smp.h  |   1 -
 arch/mips/include/asm/time.h |  28 +++---
 arch/mips/kernel/cevt-r4k.c  |  65 ++--
 arch/mips/kernel/cpu-probe.c |   6 +-
 arch/mips/kernel/smp.c   |   5 -
 arch/mips/kernel/sync-r4k.c  | 143 ---
 arch/mips/kernel/time.c  |  22 -
 arch/mips/kvm/vz.c   |   6 ++
 arch/mips/loongson64/smp.c   |  32 +-
 include/linux/cpuhotplug.h   |   1 +
 14 files changed, 173 insertions(+), 156 deletions(-)

-- 
2.28.0.rc1



Re: [PATCH] ata: ahci: use ata_link_info() instead of ata_link_printk()

2020-08-16 Thread Jens Axboe
On 8/16/20 8:29 PM, Xu Wang wrote:
> Using ata_link_info() instead of ata_link_printk().

Applied, thanks.

-- 
Jens Axboe



[PATCH 0/3] KVM: arm64: Some fixes and code adjustments for pvtime ST

2020-08-16 Thread Keqian Zhu
During picking up pvtime LPT support for arm64, I do some trivial fixes for
pvtime ST.

Keqian Zhu (3):
  KVM: arm64: Some fixes of PV-time interface document
  KVM: uapi: Remove KVM_DEV_TYPE_ARM_PV_TIME in kvm_device_type
  KVM: arm64: Use kvm_write_guest_lock when init stolen time

 Documentation/virt/kvm/arm/pvtime.rst | 6 +++---
 arch/arm64/kvm/pvtime.c   | 6 +-
 include/uapi/linux/kvm.h  | 2 --
 tools/include/uapi/linux/kvm.h| 2 --
 4 files changed, 4 insertions(+), 12 deletions(-)

-- 
1.8.3.1



[PATCH 3/3] KVM: arm64: Use kvm_write_guest_lock when init stolen time

2020-08-16 Thread Keqian Zhu
There is a lock version kvm_write_guest. Use it to simplify code.

Signed-off-by: Keqian Zhu 
---
 arch/arm64/kvm/pvtime.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/arm64/kvm/pvtime.c b/arch/arm64/kvm/pvtime.c
index f7b52ce..2b24e7f 100644
--- a/arch/arm64/kvm/pvtime.c
+++ b/arch/arm64/kvm/pvtime.c
@@ -55,7 +55,6 @@ gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu)
struct pvclock_vcpu_stolen_time init_values = {};
struct kvm *kvm = vcpu->kvm;
u64 base = vcpu->arch.steal.base;
-   int idx;
 
if (base == GPA_INVALID)
return base;
@@ -66,10 +65,7 @@ gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu)
 */
vcpu->arch.steal.steal = 0;
vcpu->arch.steal.last_steal = current->sched_info.run_delay;
-
-   idx = srcu_read_lock(&kvm->srcu);
-   kvm_write_guest(kvm, base, &init_values, sizeof(init_values));
-   srcu_read_unlock(&kvm->srcu, idx);
+   kvm_write_guest_lock(kvm, base, &init_values, sizeof(init_values));
 
return base;
 }
-- 
1.8.3.1



[PATCH 2/3] KVM: uapi: Remove KVM_DEV_TYPE_ARM_PV_TIME in kvm_device_type

2020-08-16 Thread Keqian Zhu
ARM64 PV-time ST is configured by userspace through vCPU attribute,
and KVM_DEV_TYPE_ARM_PV_TIME is unused.

Signed-off-by: Keqian Zhu 
---
 include/uapi/linux/kvm.h   | 2 --
 tools/include/uapi/linux/kvm.h | 2 --
 2 files changed, 4 deletions(-)

diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index 4fdf303..9a6b97e 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -1258,8 +1258,6 @@ enum kvm_device_type {
 #define KVM_DEV_TYPE_ARM_VGIC_ITS  KVM_DEV_TYPE_ARM_VGIC_ITS
KVM_DEV_TYPE_XIVE,
 #define KVM_DEV_TYPE_XIVE  KVM_DEV_TYPE_XIVE
-   KVM_DEV_TYPE_ARM_PV_TIME,
-#define KVM_DEV_TYPE_ARM_PV_TIME   KVM_DEV_TYPE_ARM_PV_TIME
KVM_DEV_TYPE_MAX,
 };
 
diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h
index 4fdf303..9a6b97e 100644
--- a/tools/include/uapi/linux/kvm.h
+++ b/tools/include/uapi/linux/kvm.h
@@ -1258,8 +1258,6 @@ enum kvm_device_type {
 #define KVM_DEV_TYPE_ARM_VGIC_ITS  KVM_DEV_TYPE_ARM_VGIC_ITS
KVM_DEV_TYPE_XIVE,
 #define KVM_DEV_TYPE_XIVE  KVM_DEV_TYPE_XIVE
-   KVM_DEV_TYPE_ARM_PV_TIME,
-#define KVM_DEV_TYPE_ARM_PV_TIME   KVM_DEV_TYPE_ARM_PV_TIME
KVM_DEV_TYPE_MAX,
 };
 
-- 
1.8.3.1



Re: [PATCH] Makefile: Yes. Finally remove '-Wdeclaration-after-statement'

2020-08-16 Thread Michael Witten
Joe Perches (Sun, 16 Aug 2020 10:56:53 -0700):

> I rather prefer block declarations instead of
> sprinkling declarations around with code.

Hey, we all have our guilty pleasures.

Fortunately, even with this patch, you'd still be able to indulge
in your preferred style, or even enforce it among contributors to
the code that you maintain.

However, the following statement should hold:

  If merged code is correct (portable, safe, etc.),
  then the kernel must build without any warning
  about that merged code.

Sometimes, code is clearest (or indeed safest) when it is written
with a variable definition that occurs at a point well within the
body of statements. Authors need to have the option to write such
code; otherwise, style ceases to be means of clarity, and instead
becomes a laborious end unto itself.

Matters of  style should  probably not be  enforced by  the build
infrastructure; style is a matter for the maintainer to enforce:

  * Perhaps there could be a  new build-time switch. By default, 
the warning can be off for  a normal build; a maintainer can 
flip the  switch to  turn it on  locally, and  thereby check 
whether a patch declares  variables unnecessarily hither and 
thither, as determined by the maintainer's taste.

  * Perhaps  `scripts/checkpatch.pl' could  be taught  about this
issue.  Though probably  easier  said than  done, the  script
could parse every modified block, and warn about declarations
after  statements (but  maybe  ignore  the declarations  that
introduce const variables).

  * Perhaps there is already linting infrastructure that could be
put to such use.

This way, good code can compile cleanly, and style can just be an
ongoing topic of discussion among contributors.

Sincerely,
Michael Witten


[PATCH 1/3] KVM: arm64: Some fixes of PV-time interface document

2020-08-16 Thread Keqian Zhu
Rename PV_FEATURES tp PV_TIME_FEATURES

Signed-off-by: Keqian Zhu 
---
 Documentation/virt/kvm/arm/pvtime.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/virt/kvm/arm/pvtime.rst 
b/Documentation/virt/kvm/arm/pvtime.rst
index 687b60d..94bffe2 100644
--- a/Documentation/virt/kvm/arm/pvtime.rst
+++ b/Documentation/virt/kvm/arm/pvtime.rst
@@ -3,7 +3,7 @@
 Paravirtualized time support for arm64
 ==
 
-Arm specification DEN0057/A defines a standard for paravirtualised time
+Arm specification DEN0057/A defines a standard for paravirtualized time
 support for AArch64 guests:
 
 https://developer.arm.com/docs/den0057/a
@@ -19,8 +19,8 @@ Two new SMCCC compatible hypercalls are defined:
 
 These are only available in the SMC64/HVC64 calling convention as
 paravirtualized time is not available to 32 bit Arm guests. The existence of
-the PV_FEATURES hypercall should be probed using the SMCCC 1.1 ARCH_FEATURES
-mechanism before calling it.
+the PV_TIME_FEATURES hypercall should be probed using the SMCCC 1.1
+ARCH_FEATURES mechanism before calling it.
 
 PV_TIME_FEATURES
 = ==
-- 
1.8.3.1



[RESEND RFC v2 2/2] KVM: VMX: Enable bus lock VM exit

2020-08-16 Thread Chenyi Qiang
Virtual Machine can exploit bus locks to degrade the performance of
system. Bus lock can be caused by split locked access to writeback(WB)
memory or by using locks on uncacheable(UC) memory. The bus lock is
typically >1000 cycles slower than an atomic operation within a cache
line. It also disrupts performance on other cores (which must wait for
the bus lock to be released before their memory operations can
complete).

To address the threat, bus lock VM exit is introduced to notify the VMM
when a bus lock was acquired, allowing it to enforce throttling or other
policy based mitigations.

A VMM can enable VM exit due to bus locks by setting a new "Bus Lock
Detection" VM-execution control(bit 30 of Secondary Processor-based VM
execution controls). If delivery of this VM exit was preempted by a
higher priority VM exit (e.g. EPT misconfiguration, EPT violation, APIC
access VM exit, APIC write VM exit, exception bitmap exiting), bit 26 of
exit reason in vmcs field is set to 1.

In current implementation, the KVM exposes this capability through
KVM_CAP_X86_BLD. The user can set it to enable the bus lock VM exit
(disabled by default). If bus locks in guest are detected by KVM, exit
to user space even when current exit reason is handled by KVM
internally. Set a new field KVM_RUN_BUS_LOCK in vcpu->run->flags to
inform the user space that there is a bus lock in guest and it is
preempted by a higher priority VM exit.

Every bus lock acquired in non-root mode will be recorded in
vcpu->stat.bus_locks and exposed through debugfs when the bus lock
VM exit is enabled.

Document for Bus Lock VM exit is now available at the latest "Intel
Architecture Instruction Set Extensions Programming Reference".

Document Link:
https://software.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html

Co-developed-by: Xiaoyao Li 
Signed-off-by: Xiaoyao Li 
Signed-off-by: Chenyi Qiang 
---
 arch/x86/include/asm/kvm_host.h|  9 
 arch/x86/include/asm/vmx.h |  1 +
 arch/x86/include/asm/vmxfeatures.h |  1 +
 arch/x86/include/uapi/asm/kvm.h|  1 +
 arch/x86/include/uapi/asm/vmx.h|  4 +++-
 arch/x86/kvm/vmx/capabilities.h|  6 +
 arch/x86/kvm/vmx/vmx.c | 33 ++-
 arch/x86/kvm/vmx/vmx.h |  2 +-
 arch/x86/kvm/x86.c | 36 +-
 arch/x86/kvm/x86.h |  5 +
 include/uapi/linux/kvm.h   |  2 ++
 11 files changed, 96 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 5ab3af7275d8..fc02fa95cb70 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -788,6 +788,9 @@ struct kvm_vcpu_arch {
 
/* AMD MSRC001_0015 Hardware Configuration */
u64 msr_hwcr;
+
+   /* Set when bus lock VM exit is preempted by a higher priority VM exit 
*/
+   bool bus_lock_detected;
 };
 
 struct kvm_lpage_info {
@@ -961,6 +964,9 @@ struct kvm_arch {
bool guest_can_read_msr_platform_info;
bool exception_payload_enabled;
 
+   /* Set when bus lock vm exit is enabled by user */
+   bool bus_lock_exit;
+
struct kvm_pmu_event_filter *pmu_event_filter;
struct task_struct *nx_lpage_recovery_thread;
 };
@@ -1010,6 +1016,7 @@ struct kvm_vcpu_stat {
u64 req_event;
u64 halt_poll_success_ns;
u64 halt_poll_fail_ns;
+   u64 bus_locks;
 };
 
 struct x86_instruction_info;
@@ -1347,6 +1354,8 @@ extern u8   kvm_tsc_scaling_ratio_frac_bits;
 extern u64  kvm_max_tsc_scaling_ratio;
 /* 1ull << kvm_tsc_scaling_ratio_frac_bits */
 extern u64  kvm_default_tsc_scaling_ratio;
+/* bus lock detection supported */
+extern bool kvm_has_bus_lock_exit;
 
 extern u64 kvm_mce_cap_supported;
 
diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index cd7de4b401fe..93a880bc31a7 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -73,6 +73,7 @@
 #define SECONDARY_EXEC_PT_USE_GPA  VMCS_CONTROL_BIT(PT_USE_GPA)
 #define SECONDARY_EXEC_TSC_SCALING  VMCS_CONTROL_BIT(TSC_SCALING)
 #define SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE   VMCS_CONTROL_BIT(USR_WAIT_PAUSE)
+#define SECONDARY_EXEC_BUS_LOCK_DETECTION  
VMCS_CONTROL_BIT(BUS_LOCK_DETECTION)
 
 #define PIN_BASED_EXT_INTR_MASK VMCS_CONTROL_BIT(INTR_EXITING)
 #define PIN_BASED_NMI_EXITING   VMCS_CONTROL_BIT(NMI_EXITING)
diff --git a/arch/x86/include/asm/vmxfeatures.h 
b/arch/x86/include/asm/vmxfeatures.h
index 9915990fd8cf..e80523346274 100644
--- a/arch/x86/include/asm/vmxfeatures.h
+++ b/arch/x86/include/asm/vmxfeatures.h
@@ -83,5 +83,6 @@
 #define VMX_FEATURE_TSC_SCALING( 2*32+ 25) /* Scale hardware 
TSC when read in guest */
 #define VMX_FEATURE_USR_WAIT_PAUSE ( 2*32+ 26) /* Enable TPAUSE, UMONITOR, 
UMWAIT in guest */
 #define VMX_FEATURE_ENCLV_EXITING  ( 2

[RESEND RFC v2 1/2] KVM: VMX: Convert vcpu_vmx.exit_reason to a union

2020-08-16 Thread Chenyi Qiang
From: Sean Christopherson 

Convert vcpu_vmx.exit_reason from a u32 to a union (of size u32).  The
full VM_EXIT_REASON field is comprised of a 16-bit basic exit reason in
bits 15:0, and single-bit modifiers in bits 31:16.

Historically, KVM has only had to worry about handling the "failed
VM-Entry" modifier, which could only be set in very specific flows and
required dedicated handling.  I.e. manually stripping the FAILED_VMENTRY
bit was a somewhat viable approach.  But even with only a single bit to
worry about, KVM has had several bugs related to comparing a basic exit
reason against the full exit reason store in vcpu_vmx.

Upcoming Intel features, e.g. SGX, will add new modifier bits that can
be set on more or less any VM-Exit, as opposed to the significantly more
restricted FAILED_VMENTRY, i.e. correctly handling everything in one-off
flows isn't scalable.  Tracking exit reason in a union forces code to
explicitly choose between consuming the full exit reason and the basic
exit, and is a convenient way to document and access the modifiers.

No functional change intended.

Cc: Xiaoyao Li 
Signed-off-by: Sean Christopherson 
---
 arch/x86/kvm/vmx/nested.c | 42 -
 arch/x86/kvm/vmx/vmx.c| 64 ---
 arch/x86/kvm/vmx/vmx.h| 25 ++-
 3 files changed, 84 insertions(+), 47 deletions(-)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 23b58c28a1c9..0262111e5821 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -3304,7 +3304,11 @@ enum nvmx_vmentry_status 
nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,
struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
enum vm_entry_failure_code entry_failure_code;
bool evaluate_pending_interrupts;
-   u32 exit_reason, failed_index;
+   union vmx_exit_reason exit_reason = {
+   .basic = EXIT_REASON_INVALID_STATE,
+   .failed_vmentry = 1,
+   };
+   u32 failed_index;
 
if (kvm_check_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu))
kvm_vcpu_flush_tlb_current(vcpu);
@@ -3354,7 +3358,7 @@ enum nvmx_vmentry_status 
nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,
 
if (nested_vmx_check_guest_state(vcpu, vmcs12,
 &entry_failure_code)) {
-   exit_reason = EXIT_REASON_INVALID_STATE;
+   exit_reason.basic = EXIT_REASON_INVALID_STATE;
vmcs12->exit_qualification = entry_failure_code;
goto vmentry_fail_vmexit;
}
@@ -3365,7 +3369,7 @@ enum nvmx_vmentry_status 
nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,
vcpu->arch.tsc_offset += vmcs12->tsc_offset;
 
if (prepare_vmcs02(vcpu, vmcs12, &entry_failure_code)) {
-   exit_reason = EXIT_REASON_INVALID_STATE;
+   exit_reason.basic = EXIT_REASON_INVALID_STATE;
vmcs12->exit_qualification = entry_failure_code;
goto vmentry_fail_vmexit_guest_mode;
}
@@ -3375,7 +3379,7 @@ enum nvmx_vmentry_status 
nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,
   
vmcs12->vm_entry_msr_load_addr,
   
vmcs12->vm_entry_msr_load_count);
if (failed_index) {
-   exit_reason = EXIT_REASON_MSR_LOAD_FAIL;
+   exit_reason.basic = EXIT_REASON_MSR_LOAD_FAIL;
vmcs12->exit_qualification = failed_index;
goto vmentry_fail_vmexit_guest_mode;
}
@@ -3443,7 +3447,7 @@ enum nvmx_vmentry_status 
nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,
return NVMX_VMENTRY_VMEXIT;
 
load_vmcs12_host_state(vcpu, vmcs12);
-   vmcs12->vm_exit_reason = exit_reason | VMX_EXIT_REASONS_FAILED_VMENTRY;
+   vmcs12->vm_exit_reason = exit_reason.full;
if (enable_shadow_vmcs || vmx->nested.hv_evmcs)
vmx->nested.need_vmcs12_to_shadow_sync = true;
return NVMX_VMENTRY_VMEXIT;
@@ -5488,7 +5492,12 @@ static int handle_vmfunc(struct kvm_vcpu *vcpu)
return kvm_skip_emulated_instruction(vcpu);
 
 fail:
-   nested_vmx_vmexit(vcpu, vmx->exit_reason,
+   /*
+* This is effectively a reflected VM-Exit, as opposed to a synthesized
+* nested VM-Exit.  Pass the original exit reason, i.e. don't hardcode
+* EXIT_REASON_VMFUNC as the exit reason.
+*/
+   nested_vmx_vmexit(vcpu, vmx->exit_reason.full,
  vmx_get_intr_info(vcpu),
  vmx_get_exit_qual(vcpu));
return 1;
@@ -5556,7 +5565,8 @@ static bool nested_vmx_exit_handled_io(struct kvm_vcpu 
*vcpu,
  * MSR bitmap. This may be the case even when L0 doesn't use MSR bitmaps.
  */
 static bool nested_vmx_exit_handled_msr(struct kvm

[RESEND RFC v2 0/2] add bus lock VM exit support

2020-08-16 Thread Chenyi Qiang
Resend to rebase on 5.9-rc1.

---

Add the support for bus lock VM exit in KVM. It is a sub-feature of bus
lock detection. Another sub-feature named bus lock debug exception is
blocked due to requirement to rework the HW design:
https://lore.kernel.org/lkml/87r1stmi1x@nanos.tec.linutronix.de/

In this patch series, the first patch applies Sean's refactor to
vcpu_vmx.exit_reason available at
https://patchwork.kernel.org/patch/11500659.
It is necessary as bus lock VM exit adds a new modifier bit(bit 26) in
exit_reason field in VMCS.

The second patch is the enabling work for bus lock VM exit. Add the
support to set the capability to enable bus lock vm exit. The current
implementation just exit to user space when handling the bus lock
detected in guest.

The concrete throttling policy in user space still needs to be
discussed. We can enforce ratelimit on bus lock in guest, just inject
some sleep time, or any other ideas?

Document for Bus Lock Detection is now available at the latest "Intel
Architecture Instruction Set Extensions Programming Reference".

Document Link:
https://software.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html


v1->v2 Changelogs:
- resolve Vitaly's comment to introduce the KVM_EXIT_BUS_LOCK and a
  capability to enable it.
- add the support to exit to user space when handling bus locks.
- extend the vcpu->run->flags to indicate bus lock detected for other
  exit reasons when exiting to user space.

Chenyi Qiang (1):
  KVM: VMX: Enable bus lock VM exit

Sean Christopherson (1):
  KVM: VMX: Convert vcpu_vmx.exit_reason to a union

 arch/x86/include/asm/kvm_host.h|  9 +++
 arch/x86/include/asm/vmx.h |  1 +
 arch/x86/include/asm/vmxfeatures.h |  1 +
 arch/x86/include/uapi/asm/kvm.h|  1 +
 arch/x86/include/uapi/asm/vmx.h|  4 +-
 arch/x86/kvm/vmx/capabilities.h|  6 ++
 arch/x86/kvm/vmx/nested.c  | 42 -
 arch/x86/kvm/vmx/vmx.c | 97 --
 arch/x86/kvm/vmx/vmx.h | 25 +++-
 arch/x86/kvm/x86.c | 36 ++-
 arch/x86/kvm/x86.h |  5 ++
 include/uapi/linux/kvm.h   |  2 +
 12 files changed, 179 insertions(+), 50 deletions(-)

-- 
2.17.1



[PATCH] ata: ahci: use ata_link_info() instead of ata_link_printk()

2020-08-16 Thread Xu Wang
Using ata_link_info() instead of ata_link_printk().

Signed-off-by: Xu Wang 
---
 drivers/ata/ahci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 0c0a736eb861..fbd8eaa32d32 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -807,8 +807,7 @@ static int ahci_avn_hardreset(struct ata_link *link, 
unsigned int *class,
(sstatus & 0xf) != 1)
break;
 
-   ata_link_printk(link, KERN_INFO, "avn bounce port%d\n",
-   port);
+   ata_link_info(link,  "avn bounce port%d\n", port);
 
pci_read_config_word(pdev, 0x92, &val);
val &= ~(1 << port);
-- 
2.17.1



[PATCH] upcall: Remove unneeded variable insize

2020-08-16 Thread Xu Wang
Remove unneeded variable insize in venus_pioctl().

Signed-off-by: Xu Wang 
---
 fs/coda/upcall.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index eb3b1898da46..903bd7a4ee16 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -477,10 +477,9 @@ int venus_pioctl(struct super_block *sb, struct CodaFid 
*fid,
 {
 union inputArgs *inp;
 union outputArgs *outp;  
-   int insize, outsize, error;
+   int outsize, error;
int iocsize;
 
-   insize = VC_MAXMSGSIZE;
UPARG(CODA_IOCTL);
 
 /* build packet for Venus */
-- 
2.17.1



[PATCH v8 0/2] phy: Add USB PHY support on Intel LGM SoC

2020-08-16 Thread Ramuthevar,Vadivel MuruganX
The USB PHY provides the optimized for low power dissipation while active, 
idle, or on standby.
Requires minimal external components, a single resistor, for best operation.
Supports 10/5-Gbps high-speed data transmission rates through 3-m USB 3.x cable
---
v8:
  - Rebase to V5.9-rc1
v7:
  - No Change
v6:
  - No Change
v5:
  - As per Felipe and Greg's suggestion usb phy driver reviewed patches
changed the folder from drivers/usb/phy to drivers/phy
  - Reviewed-By tag added in commit message
v4:
  - Andy's review comments addressed
  - drop the excess error debug prints
  - error check optimized
  - merge the split line to one line
v3:
  - Andy's review comments update
  - hardcode return value changed to actual return value from the callee
  - add error check is fixed according to the above
  - correct the assignment in redundant
  - combine the split line into one line
v2:
  - Address Phillip's review comments
  - replace devm_reset_control_get() by devm_reset_control_get_exclusive()
  - re-design the assert and deassert fucntion calls as per review comments
  - address kbuild bot warnings
  - add the comments
v1:
  - initial version

---
dt-bindings: usb: Add USB PHY support for Intel LGM SoC
v8:
  - No Change
v7:
  - Fixed the bot issue: usb-phy@e7e0: '#phy-cells' is a required property
v6:
  - Fixed the bot issue.
  - replace node-name by usb-phy@ in example
v5:
  - Reviewed-By tag added
v4:
  - No Change
v3:
  - No Change
v2:
  - No Change
v1:
  - initial version

Ramuthevar Vadivel Murugan (2):
  dt-bindings: phy: Add USB PHY support for Intel LGM SoC
  phy: Add USB3 PHY support for Intel LGM SoC

 .../devicetree/bindings/phy/intel,lgm-usb-phy.yaml |  58 +
 drivers/phy/Kconfig|  11 +
 drivers/phy/Makefile   |   3 +-
 drivers/phy/phy-lgm-usb.c  | 278 +
 4 files changed, 349 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/phy/intel,lgm-usb-phy.yaml
 create mode 100644 drivers/phy/phy-lgm-usb.c

-- 
2.11.0



[PATCH v8 2/2] phy: Add USB3 PHY support for Intel LGM SoC

2020-08-16 Thread Ramuthevar,Vadivel MuruganX
From: Ramuthevar Vadivel Murugan 

Add support for USB PHY on Intel LGM SoC.

Signed-off-by: Ramuthevar Vadivel Murugan 

Reviewed-by: Philipp Zabel 
---
 drivers/phy/Kconfig   |  11 ++
 drivers/phy/Makefile  |   3 +-
 drivers/phy/phy-lgm-usb.c | 278 ++
 3 files changed, 291 insertions(+), 1 deletion(-)
 create mode 100644 drivers/phy/phy-lgm-usb.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index de9362c25c07..01b53f86004c 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -49,6 +49,17 @@ config PHY_XGENE
help
  This option enables support for APM X-Gene SoC multi-purpose PHY.
 
+config USB_LGM_PHY
+   tristate "INTEL Lightning Mountain USB PHY Driver"
+   depends on USB_SUPPORT
+   select USB_PHY
+   select REGULATOR
+   select REGULATOR_FIXED_VOLTAGE
+   help
+ Enable this to support Intel DWC3 PHY USB phy. This driver provides
+ interface to interact with USB GEN-II and USB 3.x PHY that is part
+ of the Intel network SOC.
+
 source "drivers/phy/allwinner/Kconfig"
 source "drivers/phy/amlogic/Kconfig"
 source "drivers/phy/broadcom/Kconfig"
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index c27408e4daae..90030ff299eb 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -1,4 +1,4 @@
-# SPDX-License-Identifier: GPL-2.0
+PDX-License-Identifier: GPL-2.0
 #
 # Makefile for the phy drivers.
 #
@@ -8,6 +8,7 @@ obj-$(CONFIG_GENERIC_PHY_MIPI_DPHY) += phy-core-mipi-dphy.o
 obj-$(CONFIG_PHY_LPC18XX_USB_OTG)  += phy-lpc18xx-usb-otg.o
 obj-$(CONFIG_PHY_XGENE)+= phy-xgene.o
 obj-$(CONFIG_PHY_PISTACHIO_USB)+= phy-pistachio-usb.o
+obj-$(CONFIG_USB_LGM_PHY)  += phy-lgm-usb.o
 obj-y  += allwinner/   \
   amlogic/ \
   broadcom/\
diff --git a/drivers/phy/phy-lgm-usb.c b/drivers/phy/phy-lgm-usb.c
new file mode 100644
index ..1ec9ab266e08
--- /dev/null
+++ b/drivers/phy/phy-lgm-usb.c
@@ -0,0 +1,278 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Intel LGM USB PHY driver
+ *
+ * Copyright (C) 2020 Intel Corporation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define CTRL1_OFFSET   0x14
+#define SRAM_EXT_LD_DONE   BIT(25)
+#define SRAM_INIT_DONE BIT(26)
+
+#define TCPC_OFFSET0x1014
+#define TCPC_MUX_CTL   GENMASK(1, 0)
+#define MUX_NC 0
+#define MUX_USB1
+#define MUX_DP 2
+#define MUX_USBDP  3
+#define TCPC_FLIPPED   BIT(2)
+#define TCPC_LOW_POWER_EN  BIT(3)
+#define TCPC_VALID BIT(4)
+#define TCPC_CONN  \
+   (TCPC_VALID | FIELD_PREP(TCPC_MUX_CTL, MUX_USB))
+#define TCPC_DISCONN   \
+   (TCPC_VALID | FIELD_PREP(TCPC_MUX_CTL, MUX_NC) | TCPC_LOW_POWER_EN)
+
+static const char *const PHY_RESETS[] = { "phy31", "phy", };
+static const char *const CTL_RESETS[] = { "apb", "ctrl", };
+
+struct tca_apb {
+   struct reset_control *resets[ARRAY_SIZE(PHY_RESETS)];
+   struct regulator *vbus;
+   struct work_struct wk;
+   struct usb_phy phy;
+
+   bool phy_initialized;
+   bool connected;
+};
+
+static int get_flipped(struct tca_apb *ta, bool *flipped)
+{
+   union extcon_property_value property;
+   int ret;
+
+   ret = extcon_get_property(ta->phy.edev, EXTCON_USB_HOST,
+ EXTCON_PROP_USB_TYPEC_POLARITY, &property);
+   if (ret) {
+   dev_err(ta->phy.dev, "no polarity property from extcon\n");
+   return ret;
+   }
+
+   *flipped = property.intval;
+
+   return ret;
+}
+
+static int phy_init(struct usb_phy *phy)
+{
+   struct tca_apb *ta = container_of(phy, struct tca_apb, phy);
+   void __iomem *ctrl1 = phy->io_priv + CTRL1_OFFSET;
+   int val, ret, i;
+
+   if (ta->phy_initialized)
+   return 0;
+
+   for (i = 0; i < ARRAY_SIZE(PHY_RESETS); i++)
+   reset_control_deassert(ta->resets[i]);
+
+   ret = readl_poll_timeout(ctrl1, val, val & SRAM_INIT_DONE, 10, 10 * 
1000);
+   if (ret) {
+   dev_err(ta->phy.dev, "SRAM init failed, 0x%x\n", val);
+   return ret;
+   }
+
+   writel(readl(ctrl1) | SRAM_EXT_LD_DONE, ctrl1);
+
+   ta->phy_initialized = true;
+   if (!ta->phy.edev) {
+   writel(TCPC_CONN, ta->phy.io_priv + TCPC_OFFSET);
+   return phy->set_vbus(phy, true);
+   }
+
+   schedule_work(&ta->wk);
+
+   return ret;
+}
+
+static void phy_shutdown(struct usb_phy *phy)
+{
+   struct tca_apb *ta = container_of(phy, struct tca_apb, phy);
+   int i;
+
+   if (!ta->phy_initialized)
+   return;
+
+   ta->

  1   2   3   4   5   >