Re: [PATCH 31/31] PM / devfreq: convert to devm_pm_opp_register_notifier and remove unused API

2021-01-03 Thread Viresh Kumar
On 03-01-21, 03:57, Yangtao Li wrote:
>  Use devm_pm_opp_* API to simplify code.
> 
> Signed-off-by: Yangtao Li 
> ---
>  drivers/devfreq/devfreq.c | 66 +--
>  include/linux/devfreq.h   | 23 --
>  2 files changed, 1 insertion(+), 88 deletions(-)

Remove the unused stuff in a separate patch and let this layer keep
doing the devm thing, I don't think others would need it.

-- 
viresh


Re: [PATCH 00/31] Introduce devm_pm_opp_* API

2021-01-03 Thread Viresh Kumar
On 01-01-21, 16:54, Yangtao Li wrote:
> Hi,
> 
> This patchset add devm_pm_opp_set_clkname, devm_pm_opp_put_clkname,
> devm_pm_opp_set_regulators, devm_pm_opp_put_regulators,
> devm_pm_opp_set_supported_hw, devm_pm_opp_of_add_table and
> devm_pm_opp_register_notifier.

Please also mention next time to all the maintainers that you need
their Acks for their patches and that all these patches should get
merged via the OPP tree.

-- 
viresh


Re: [PATCH 18/31] drm/lima: remove unneeded devm_devfreq_remove_device()

2021-01-03 Thread Viresh Kumar
On 01-01-21, 16:54, Yangtao Li wrote:
> There is no need to manually release devm related resources.
> 
> Signed-off-by: Yangtao Li 
> ---
>  drivers/gpu/drm/lima/lima_devfreq.c | 5 -
>  1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/lima/lima_devfreq.c 
> b/drivers/gpu/drm/lima/lima_devfreq.c
> index d5937cf86504..7690c5c69f9f 100644
> --- a/drivers/gpu/drm/lima/lima_devfreq.c
> +++ b/drivers/gpu/drm/lima/lima_devfreq.c
> @@ -94,11 +94,6 @@ void lima_devfreq_fini(struct lima_device *ldev)
>   devfreq_cooling_unregister(devfreq->cooling);
>   devfreq->cooling = NULL;
>   }
> -
> - if (devfreq->devfreq) {
> - devm_devfreq_remove_device(ldev->dev, devfreq->devfreq);
> - devfreq->devfreq = NULL;
> - }
>  }

Why is this part of this patchset ?

-- 
viresh


Re: [PATCH] phy: mediatek: allow compile-testing the dsi phy

2021-01-03 Thread Vinod Koul
On 03-01-21, 14:55, Arnd Bergmann wrote:
> From: Arnd Bergmann 
> 
> Randconfig builds show another broken dependency:
> 
> WARNING: unmet direct dependencies detected for PHY_MTK_MIPI_DSI
>   Depends on [n]: ARCH_MEDIATEK [=n] && OF [=y]
>   Selected by [m]:
>   - DRM_MEDIATEK [=m] && HAS_IOMEM [=y] && DRM [=m] && (ARCH_MEDIATEK [=n] || 
> ARM [=y] && COMPILE_TEST [=y]) && COMMON_CLK [=y] &&
> HAVE_ARM_SMCCC [=y] && OF [=y] && MTK_MMSYS [=y]
> 
> This is similar to the hdmi driver I fixed earlier, and I guess the
> common-clk bug would sooner or later also manifest here, so just use
> the exact same solution I chose for the other driver, and hope that
> any future drivers just copy it from here.

Applied, thanks

> 
> Fixes: 90f80d95992f ("phy: mediatek: Move mtk_mipi_dsi_phy driver into 
> drivers/phy/mediatek folder")
> Fixes: f5f6e01f9164 ("phy: mediatek: allow compile-testing the hdmi phy")
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/phy/mediatek/Kconfig | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/mediatek/Kconfig b/drivers/phy/mediatek/Kconfig
> index d38def43b1bf..55f8e6c048ab 100644
> --- a/drivers/phy/mediatek/Kconfig
> +++ b/drivers/phy/mediatek/Kconfig
> @@ -49,7 +49,9 @@ config PHY_MTK_HDMI
>  
>  config PHY_MTK_MIPI_DSI
>   tristate "MediaTek MIPI-DSI Driver"
> - depends on ARCH_MEDIATEK && OF
> + depends on ARCH_MEDIATEK || COMPILE_TEST
> + depends on COMMON_CLK
> + depends on OF
>   select GENERIC_PHY
>   help
> Support MIPI DSI for Mediatek SoCs.
> -- 
> 2.29.2

-- 
~Vinod


Re: [PATCH 01/31] opp: Add devres wrapper for dev_pm_opp_set_clkname and dev_pm_opp_put_clkname

2021-01-03 Thread Viresh Kumar
On 01-01-21, 16:54, Yangtao Li wrote:
> +/**
> + * devm_pm_opp_put_clkname() - Releases resources blocked for clk.
> + * @dev: Device for which we do this operation.
> + * @opp_table: OPP table returned from devm_pm_opp_set_clkname().
> + */
> +void devm_pm_opp_put_clkname(struct device *dev, struct opp_table *opp_table)
> +{
> + devm_release_action(dev, devm_pm_opp_clkname_release, opp_table);
> +}
> +EXPORT_SYMBOL_GPL(devm_pm_opp_put_clkname);

We shouldn't be needing changes like this, please drop them for all
patches.

-- 
viresh


Re: [PATCH] pcmcia: Switch to using the new API kobj_to_dev()

2021-01-03 Thread Dominik Brodowski
Am Mon, Jan 04, 2021 at 09:59:30AM +0800 schrieb Tian Tao:
> fixed the following coccicheck:
> drivers/pcmcia/cistpl.c:1557:54-55: WARNING opportunity for kobj_to_dev()
> drivers/pcmcia/cistpl.c:1584:53-54: WARNING opportunity for kobj_to_dev()
> 
> Signed-off-by: Tian Tao 

Applied to pcmcia-next, thanks!

Dominik


Re: [PATCH] phy: cpcap-usb: Fix warning for missing regulator_disable

2021-01-03 Thread Vinod Koul
On 30-12-20, 12:21, Tony Lindgren wrote:
> On deferred probe, we will get the following splat:
> 
> cpcap-usb-phy cpcap-usb-phy.0: could not initialize VBUS or ID IIO: -517
> WARNING: CPU: 0 PID: 21 at drivers/regulator/core.c:2123 
> regulator_put+0x68/0x78
> ...
> (regulator_put) from [] (release_nodes+0x1b4/0x1fc)
> (release_nodes) from [] (really_probe+0x104/0x4a0)
> (really_probe) from [] (driver_probe_device+0x58/0xb4)

Applied, thanks

-- 
~Vinod


Re: [PATCH 26/31] PM / devfreq: tegra30: convert to use devm_pm_opp_* API

2021-01-03 Thread Viresh Kumar
On 03-01-21, 03:54, Yangtao Li wrote:
> Use devm_pm_opp_* API to simplify code, and remove opp_table
> from tegra_devfreq.

Patches starting this one didn't appear in the same thread and it is a
nightmare to apply these now. Please send everything properly next
time.

-- 
viresh


[PATCH v2] ovl: use a dedicated semaphore for dir upperfile caching

2021-01-03 Thread Icenowy Zheng
The function ovl_dir_real_file() currently uses the semaphore of the
inode to synchronize write to the upperfile cache field.

However, this function will get called by ovl_ioctl_set_flags(), which
utilizes the inode semaphore too. In this case ovl_dir_real_file() will
try to claim a lock that is owned by a function in its call stack, which
won't get released before ovl_dir_real_file() returns.

Define a dedicated semaphore for the upperfile cache, so that the
deadlock won't happen.

Fixes: 61536bed2149 ("ovl: support [S|G]ETFLAGS and FS[S|G]ETXATTR ioctls for 
directories")
Cc: sta...@vger.kernel.org # v5.10
Signed-off-by: Icenowy Zheng 
---
 fs/overlayfs/readdir.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 01620ebae1bd..fa1844ff8db4 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -56,6 +56,7 @@ struct ovl_dir_file {
struct list_head *cursor;
struct file *realfile;
struct file *upperfile;
+   struct semaphore upperfile_sem;
 };
 
 static struct ovl_cache_entry *ovl_cache_entry_from_node(struct rb_node *n)
@@ -874,8 +875,6 @@ struct file *ovl_dir_real_file(const struct file *file, 
bool want_upper)
 * Need to check if we started out being a lower dir, but got copied up
 */
if (!od->is_upper) {
-   struct inode *inode = file_inode(file);
-
realfile = READ_ONCE(od->upperfile);
if (!realfile) {
struct path upperpath;
@@ -883,10 +882,10 @@ struct file *ovl_dir_real_file(const struct file *file, 
bool want_upper)
ovl_path_upper(dentry, );
realfile = ovl_dir_open_realfile(file, );
 
-   inode_lock(inode);
+   down(>upperfile_sem);
if (!od->upperfile) {
if (IS_ERR(realfile)) {
-   inode_unlock(inode);
+   up(>upperfile_sem);
return realfile;
}
smp_store_release(>upperfile, realfile);
@@ -896,7 +895,7 @@ struct file *ovl_dir_real_file(const struct file *file, 
bool want_upper)
fput(realfile);
realfile = od->upperfile;
}
-   inode_unlock(inode);
+   up(>upperfile_sem);
}
}
 
@@ -959,6 +958,7 @@ static int ovl_dir_open(struct inode *inode, struct file 
*file)
od->realfile = realfile;
od->is_real = ovl_dir_is_real(file->f_path.dentry);
od->is_upper = OVL_TYPE_UPPER(type);
+   sema_init(>upperfile_sem, 1);
file->private_data = od;
 
return 0;
-- 
2.28.0


Re: [PATCH 07/31] serial: qcom_geni_serial: convert to use devm_pm_opp_* API

2021-01-03 Thread Viresh Kumar
Dropped lots of people from cc list

On 04-01-21, 12:49, Viresh Kumar wrote:
> On 01-01-21, 16:54, Yangtao Li wrote:
> > Use devm_pm_opp_* API to simplify code, and we don't need
> > to make opp_table glabal.
> > 
> > Let's remove opp_table from geni_se later.
> > 
> > Signed-off-by: Yangtao Li 
> > ---
> >  drivers/tty/serial/qcom_geni_serial.c | 23 +--
> >  1 file changed, 9 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/tty/serial/qcom_geni_serial.c 
> > b/drivers/tty/serial/qcom_geni_serial.c
> > index 5aada7ebae35..36a92df8ec11 100644
> > --- a/drivers/tty/serial/qcom_geni_serial.c
> > +++ b/drivers/tty/serial/qcom_geni_serial.c
> > @@ -1352,6 +1352,7 @@ static int qcom_geni_serial_probe(struct 
> > platform_device *pdev)
> > int irq;
> > bool console = false;
> > struct uart_driver *drv;
> > +   struct opp_table *opp_table;
> >  
> > if (of_device_is_compatible(pdev->dev.of_node, "qcom,geni-debug-uart"))
> > console = true;
> > @@ -1433,13 +1434,13 @@ static int qcom_geni_serial_probe(struct 
> > platform_device *pdev)
> > if (of_property_read_bool(pdev->dev.of_node, "cts-rts-swap"))
> > port->cts_rts_swap = true;
> >  
> > -   port->se.opp_table = dev_pm_opp_set_clkname(>dev, "se");
> > -   if (IS_ERR(port->se.opp_table))
> > -   return PTR_ERR(port->se.opp_table);
> > +   opp_table = devm_pm_opp_set_clkname(>dev, "se");
> > +   if (IS_ERR(opp_table))
> > +   return PTR_ERR(opp_table);
> > /* OPP table is optional */
> > -   ret = dev_pm_opp_of_add_table(>dev);
> > +   ret = devm_pm_opp_of_add_table(>dev);
> > if (ret) {
> > -   dev_pm_opp_put_clkname(port->se.opp_table);
> > +   devm_pm_opp_put_clkname(>dev, opp_table);
> 
> We shouldn't be doing this here, i.e. put_clkname. Even when the OPP
> table isn't present, this driver calls dev_pm_opp_set_rate() which
> behaves like clk_set_rate() in this case and so the clk name is still
> required by the OPP core.

The same problem is there with multiple patches, fix them all please.

-- 
viresh


Re: [PATCH] ovl: use a dedicated semaphore for dir upperfile caching

2021-01-03 Thread Icenowy Zheng
在 2021-01-03星期日的 16:10 +0200,Amir Goldstein写道:
> On Fri, Jan 1, 2021 at 10:12 PM Icenowy Zheng 
> wrote:
> > 
> > The function ovl_dir_real_file() currently uses the semaphore of
> > the
> > inode to synchronize write to the upperfile cache field.
> > 
> > However, this function will get called by ovl_ioctl_set_flags(),
> > which
> > utilizes the inode semaphore too. In this case ovl_dir_real_file()
> > will
> > try to claim a lock that is owned by a function in its call stack,
> > which
> > won't get released before ovl_dir_real_file() returns.
> 
> oops. I wondered why I didn't see any warnings on this from lockdep.
> Ah! because the xfstest that exercises ovl_ioctl_set_flags() on
> directory,
> generic/079, starts with an already upper dir.
> 
> And the xfstest that checks chattr+i on lower/upper files,
> overlay/040,
> does not check chattr on dirs (ioctl on overlay dirs wasn't supported
> at
> the time the test was written).
> 
> Would you be able to create a variant of test overlay/040 that also
> tests
> chattr +i on lower/upper dirs to test your patch and confirm that the
> test
> fails on master with the appropriate Kconfig debug options.

https://gist.github.com/Icenowy/c7d8decb6812d6e5064d143c57281ad3

Here's a test that would break on master (I used linux-next/master for
test).

[  246.521880] INFO: task chattr:715 blocked for more than 122 seconds.
[  246.525659]   Not tainted 5.11.0-rc1-next-20210104+ #20
[  246.528498] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs"
disables this message.
[  246.535076] task:chattr  state:D stack:13736 pid:  715 ppid:
529 flags:0x
[  246.538923] Call Trace:
[  246.540241]  __schedule+0x2a9/0x820
[  246.541986]  schedule+0x56/0xc0
[  246.543616]  rwsem_down_write_slowpath+0x375/0x630
[  246.545565]  ovl_dir_real_file+0xc1/0x120
[  246.547512]  ovl_real_fdget+0x35/0x80
[  246.549303]  ovl_real_ioctl+0x26/0x90
[  246.551050]  ? mnt_drop_write+0x2c/0x70
[  246.553068]  ovl_ioctl_set_flags+0x93/0x110
[  246.555407]  __x64_sys_ioctl+0x7e/0xb0
[  246.557175]  do_syscall_64+0x33/0x40
[  246.558869]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[  246.561057] RIP: 0033:0x7fe4a3830b67
[  246.565799] RSP: 002b:7ffe7ad504f8 EFLAGS: 0246 ORIG_RAX:
0010
[  246.569438] RAX: ffda RBX: 0001 RCX:
7fe4a3830b67
[  246.572061] RDX: 7ffe7ad5050c RSI: 40086602 RDI:
0003
[  246.575509] RBP: 0003 R08: 0001 R09:

[  246.578932] R10:  R11: 0246 R12:
0010
[  246.581014] R13: 7ffe7ad50810 R14: 0002 R15:
0001
[  246.582818] 
[  246.582818] Showing all locks held in the system:
[  246.584741] 1 lock held by khungtaskd/18:
[  246.586085]  #0: 9e951540 (rcu_read_lock){}-{1:2}, at:
debug_show_all_locks+0x15/0x100
[  246.589775] 3 locks held by chattr/715:
[  246.591364]  #0: 96a74b92c450 (sb_writers#11){}-{0:0}, at:
ovl_ioctl_set_flags+0x2f/0x110
[  246.597182]  #1: 96a7489c3500
(_i_mutex_dir_key[depth]){}-{3:3}, at:
ovl_ioctl_set_flags+0x54/0x110
[  246.601325]  #2: 96a7489c3500
(_i_mutex_dir_key[depth]){}-{3:3}, at:
ovl_dir_real_file+0xc1/0x120

> 
> > 
> > Define a dedicated semaphore for the upperfile cache, so that the
> > deadlock won't happen.
> > 
> > Fixes: 61536bed2149 ("ovl: support [S|G]ETFLAGS and FS[S|G]ETXATTR
> > ioctls for directories")
> > Cc: sta...@vger.kernel.org # v5.10
> > Signed-off-by: Icenowy Zheng 
> > ---
> >  fs/overlayfs/readdir.c | 6 --
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
> > index 01620ebae1bd..f10701aabb71 100644
> > --- a/fs/overlayfs/readdir.c
> > +++ b/fs/overlayfs/readdir.c
> > @@ -56,6 +56,7 @@ struct ovl_dir_file {
> >     struct list_head *cursor;
> >     struct file *realfile;
> >     struct file *upperfile;
> > +   struct semaphore upperfile_sem;
> 
> mutex please
> 
> >  };
> > 
> >  static struct ovl_cache_entry *ovl_cache_entry_from_node(struct
> > rb_node *n)
> > @@ -883,7 +884,7 @@ struct file *ovl_dir_real_file(const struct
> > file *file, bool want_upper)
> >     ovl_path_upper(dentry, );
> >     realfile = ovl_dir_open_realfile(file,
> > );
> > 
> > -   inode_lock(inode);
> > +   down(>upperfile_sem);
> >     if (!od->upperfile) {
> >     if (IS_ERR(realfile)) {
> >     inode_unlock(inode);
> 
> You missed this unlock

Thanks, will send v2 now.

> 
> Thanks,
> Amir.



Re: [PATCH 00/31] Introduce devm_pm_opp_* API

2021-01-03 Thread Viresh Kumar
On 01-01-21, 16:54, Yangtao Li wrote:
> Hi,
> 
> This patchset add devm_pm_opp_set_clkname, devm_pm_opp_put_clkname,
> devm_pm_opp_set_regulators, devm_pm_opp_put_regulators,
> devm_pm_opp_set_supported_hw, devm_pm_opp_of_add_table and
> devm_pm_opp_register_notifier.

You can't put so many names in the cclist, we are getting failure
messages while replying to your patches now.

Put all people you want to inform in the bcc section and only the
important ones in to/cc list.

-- 
viresh


Re: [PATCH] drm/msm/a6xx: add CONFIG_QCOM_LLCC dependency

2021-01-03 Thread Sai Prakash Ranjan

Hi Arnd,

On 2021-01-03 20:54, Arnd Bergmann wrote:

On Sun, Jan 3, 2021 at 4:09 PM kernel test robot  wrote:


Hi Arnd,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.11-rc1 next-20201223]
[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/Arnd-Bergmann/drm-msm-a6xx-add-CONFIG_QCOM_LLCC-dependency/20210103-220704
base:   
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
3516bd729358a2a9b090c1905bd2a3fa926e24c6

config: i386-randconfig-m021-20210103 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
# 
https://github.com/0day-ci/linux/commit/7d8b8d7954012e210a5e6c77103e52382c6b5503

git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Arnd-Bergmann/drm-msm-a6xx-add-CONFIG_QCOM_LLCC-dependency/20210103-220704

git checkout 7d8b8d7954012e210a5e6c77103e52382c6b5503
# save the attached .config to linux build tree
make W=1 ARCH=i386

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

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/Kconfig:74:error: recursive dependency detected!
   drivers/gpu/drm/Kconfig:74: symbol DRM_KMS_HELPER is selected by 
DRM_MSM
   drivers/gpu/drm/msm/Kconfig:3: symbol DRM_MSM depends on 
QCOM_COMMAND_DB
   drivers/soc/qcom/Kconfig:19: symbol QCOM_COMMAND_DB depends on 
OF_RESERVED_MEM
   drivers/of/Kconfig:80: symbol OF_RESERVED_MEM default is visible 
depending on DMA_CMA

   kernel/dma/Kconfig:109: symbol DMA_CMA is selected by FB_HYPERV
   drivers/video/fbdev/Kconfig:2182: symbol FB_HYPERV depends on FB
   drivers/video/fbdev/Kconfig:12: symbol FB is selected by 
DRM_KMS_FB_HELPER
   drivers/gpu/drm/Kconfig:80: symbol DRM_KMS_FB_HELPER depends on 
DRM_KMS_HELPER

   For a resolution refer to Documentation/kbuild/kconfig-language.rst
   subsection "Kconfig recursive dependency limitations"


Ah, this depends on another patch of mine that I have in my randconfig 
tree, to

replace the 'select FB' in DRM_KMS_FB_HELPER with 'depends on FB'.

Should I resend that patch, or would someone suggest a different fix 
for

the CONFIG_QCOM_LLCC dependency issue?



Thanks, your patch looks good to me unless Rob has some other idea. Once 
the recursive

dependency thing is sorted,

Reviewed-by: Sai Prakash Ranjan 

Thanks,
Sai

--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a 
member

of Code Aurora Forum, hosted by The Linux Foundation


[PATCH 2/2] phy: qcom-qmp: Add support for SDX55 QMP PHY

2021-01-03 Thread Manivannan Sadhasivam
Add support for USB3 QMP PHY found in SDX55 platform. SDX55 uses
version 4.0.0 of the QMP PHY IP and doesn't make use of "com_aux" clock.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 83 +
 1 file changed, 83 insertions(+)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 0939a9e9d448..bdcb8bf6225d 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -1974,6 +1974,53 @@ static const struct qmp_phy_init_tbl 
sm8250_qmp_gen3x2_pcie_pcs_misc_tbl[] = {
QMP_PHY_INIT_CFG(QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4, 0x07),
 };
 
+static const struct qmp_phy_init_tbl sdx55_usb3_uniphy_tx_tbl[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RCV_DETECT_LVL_2, 0x12),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_1, 0xd5),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_LANE_MODE_2, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_PI_QEC_CTRL, 0x20),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x08),
+};
+
+static const struct qmp_phy_init_tbl sdx55_usb3_uniphy_rx_tbl[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH4, 0x26),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH3, 0x7f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH2, 0xbf),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_HIGH, 0x7f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_00_LOW, 0x7f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH4, 0xb4),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH3, 0x7b),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH2, 0x5c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_HIGH, 0xdc),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_MODE_01_LOW, 0xdc),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_PI_CONTROLS, 0x99),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH1, 0x048),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_THRESH2, 0x08),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN1, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SB2_GAIN2, 0x04),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_FO_GAIN, 0x2f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_LOW, 0xff),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x7f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_FO_GAIN, 0x09),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL1, 0x54),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_VGA_CAL_CNTRL2, 0x0c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3, 0x4a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_EN_TIMER, 0x04),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x47),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_CNTRL, 0x04),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL, 0x0e),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW, 0xc0),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_UCDR_SO_GAIN, 0x05),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_DCC_CTRL1, 0x0c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_RX_GM_CAL, 0x1f),
+};
+
 /* struct qmp_phy_cfg - per-PHY initialization config */
 struct qmp_phy_cfg {
/* phy-type - PCIE/UFS/USB */
@@ -2183,6 +2230,11 @@ static const char * const sdm845_ufs_phy_clk_l[] = {
"ref", "ref_aux",
 };
 
+/* usb3 phy on sdx55 doesn't have com_aux clock */
+static const char * const qmp_v4_sdx55_usbphy_clk_l[] = {
+   "aux", "cfg_ahb", "ref"
+};
+
 /* list of resets */
 static const char * const msm8996_pciephy_reset_l[] = {
"phy", "common", "cfg",
@@ -2824,6 +2876,34 @@ static const struct qmp_phy_cfg sm8250_usb3_uniphy_cfg = 
{
.pwrdn_delay_max= POWER_DOWN_DELAY_US_MAX,
 };
 
+static const struct qmp_phy_cfg sdx55_usb3_uniphy_cfg = {
+   .type   = PHY_TYPE_USB3,
+   .nlanes = 1,
+
+   .serdes_tbl = sm8150_usb3_uniphy_serdes_tbl,
+   .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_uniphy_serdes_tbl),
+   .tx_tbl = sdx55_usb3_uniphy_tx_tbl,
+   .tx_tbl_num = ARRAY_SIZE(sdx55_usb3_uniphy_tx_tbl),
+   .rx_tbl = sdx55_usb3_uniphy_rx_tbl,
+   .rx_tbl_num = ARRAY_SIZE(sdx55_usb3_uniphy_rx_tbl),
+   .pcs_tbl= sm8250_usb3_uniphy_pcs_tbl,
+   .pcs_tbl_num= ARRAY_SIZE(sm8250_usb3_uniphy_pcs_tbl),
+   .clk_list   = qmp_v4_sdx55_usbphy_clk_l,
+   .num_clks   = ARRAY_SIZE(qmp_v4_sdx55_usbphy_clk_l),
+   .reset_list = 

[PATCH 1/2] dt-bindings: phy: qcom,qmp: Add SDX55 USB PHY binding

2021-01-03 Thread Manivannan Sadhasivam
Add devicetree YAML binding for Qualcomm QMP Super Speed (SS) PHY found
in SDX55.

Signed-off-by: Manivannan Sadhasivam 
---
 Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
index ec05db374645..390df23b82e7 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
@@ -34,6 +34,7 @@ properties:
   - qcom,sm8250-qmp-gen3x1-pcie-phy
   - qcom,sm8250-qmp-gen3x2-pcie-phy
   - qcom,sm8250-qmp-modem-pcie-phy
+  - qcom,sdx55-qmp-usb3-uni-phy
 
   reg:
 items:
@@ -109,6 +110,7 @@ allOf:
   contains:
 enum:
   - qcom,sdm845-qmp-usb3-uni-phy
+  - qcom,sdx55-qmp-usb3-uni-phy
 then:
   properties:
 clocks:
-- 
2.25.1



[PATCH 0/2] Add support for USB3 PHY on SDX55

2021-01-03 Thread Manivannan Sadhasivam
Hello,

This series adds USB3 PHY support for SDX55 platform. The USB3 PHY is of
type QMP and revision 4.0.0. In this revision, "com_aux" clock is not
utilized.

This series has been tested on SDX55-MTP along with the relevant DT node.

Thanks,
Mani

Manivannan Sadhasivam (2):
  dt-bindings: phy: qcom,qmp: Add SDX55 USB PHY binding
  phy: qcom-qmp: Add support for SDX55 QMP PHY

 .../devicetree/bindings/phy/qcom,qmp-phy.yaml |  2 +
 drivers/phy/qualcomm/phy-qcom-qmp.c   | 83 +++
 2 files changed, 85 insertions(+)

-- 
2.25.1



[PATCv4 net-next] octeontx2-pf: Add RSS multi group support

2021-01-03 Thread Geetha sowjanya
Hardware supports 8 RSS groups per interface. Currently we are using
only group '0'. This patch allows user to create new RSS groups/contexts
and use the same as destination for flow steering rules.

usage:
To steer the traffic to RQ 2,3

ethtool -X eth0 weight 0 0 1 1 context new
(It will print the allocated context id number)
New RSS context is 1

ethtool -N eth0 flow-type tcp4 dst-port 80 context 1 loc 1

To delete the context
ethtool -X eth0 context 1 delete

When an RSS context is removed, the active classification
rules using this context are also removed.

Change-log:

v4
- Fixed compiletime warning.
- Address Saeed's comments on v3.

v3
- Coverted otx2_set_rxfh() to use new function.

v2
- Removed unrelated whitespace
- Coverted otx2_get_rxfh() to use new function.


Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Geetha sowjanya 
---
 .../ethernet/marvell/octeontx2/nic/otx2_common.c   |  26 ++--
 .../ethernet/marvell/octeontx2/nic/otx2_common.h   |  11 +-
 .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c  | 133 -
 .../ethernet/marvell/octeontx2/nic/otx2_flows.c|  37 +-
 4 files changed, 163 insertions(+), 44 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c 
b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
index 73fb94d..bdfa2e2 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
@@ -270,14 +270,17 @@ int otx2_set_flowkey_cfg(struct otx2_nic *pfvf)
return err;
 }
 
-int otx2_set_rss_table(struct otx2_nic *pfvf)
+int otx2_set_rss_table(struct otx2_nic *pfvf, int ctx_id)
 {
struct otx2_rss_info *rss = >hw.rss_info;
+   const int index = rss->rss_size * ctx_id;
struct mbox *mbox = >mbox;
+   struct otx2_rss_ctx *rss_ctx;
struct nix_aq_enq_req *aq;
int idx, err;
 
mutex_lock(>lock);
+   rss_ctx = rss->rss_ctx[ctx_id];
/* Get memory to put this msg */
for (idx = 0; idx < rss->rss_size; idx++) {
aq = otx2_mbox_alloc_msg_nix_aq_enq(mbox);
@@ -297,10 +300,10 @@ int otx2_set_rss_table(struct otx2_nic *pfvf)
}
}
 
-   aq->rss.rq = rss->ind_tbl[idx];
+   aq->rss.rq = rss_ctx->ind_tbl[idx];
 
/* Fill AQ info */
-   aq->qidx = idx;
+   aq->qidx = index + idx;
aq->ctype = NIX_AQ_CTYPE_RSS;
aq->op = NIX_AQ_INSTOP_INIT;
}
@@ -335,9 +338,10 @@ void otx2_set_rss_key(struct otx2_nic *pfvf)
 int otx2_rss_init(struct otx2_nic *pfvf)
 {
struct otx2_rss_info *rss = >hw.rss_info;
+   struct otx2_rss_ctx *rss_ctx;
int idx, ret = 0;
 
-   rss->rss_size = sizeof(rss->ind_tbl);
+   rss->rss_size = sizeof(*rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP]);
 
/* Init RSS key if it is not setup already */
if (!rss->enable)
@@ -345,13 +349,19 @@ int otx2_rss_init(struct otx2_nic *pfvf)
otx2_set_rss_key(pfvf);
 
if (!netif_is_rxfh_configured(pfvf->netdev)) {
-   /* Default indirection table */
+   /* Set RSS group 0 as default indirection table */
+   rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP] = kzalloc(rss->rss_size,
+ GFP_KERNEL);
+   if (!rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP])
+   return -ENOMEM;
+
+   rss_ctx = rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP];
for (idx = 0; idx < rss->rss_size; idx++)
-   rss->ind_tbl[idx] =
+   rss_ctx->ind_tbl[idx] =
ethtool_rxfh_indir_default(idx,
   pfvf->hw.rx_queues);
}
-   ret = otx2_set_rss_table(pfvf);
+   ret = otx2_set_rss_table(pfvf, DEFAULT_RSS_CONTEXT_GROUP);
if (ret)
return ret;
 
@@ -986,7 +996,7 @@ int otx2_config_nix(struct otx2_nic *pfvf)
nixlf->sq_cnt = pfvf->hw.tx_queues;
nixlf->cq_cnt = pfvf->qset.cq_cnt;
nixlf->rss_sz = MAX_RSS_INDIR_TBL_SIZE;
-   nixlf->rss_grps = 1; /* Single RSS indir table supported, for now */
+   nixlf->rss_grps = MAX_RSS_GROUPS;
nixlf->xqe_sz = NIX_XQESZ_W16;
/* We don't know absolute NPA LF idx attached.
 * AF will replace 'RVU_DEFAULT_PF_FUNC' with
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h 
b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
index 1034304..143ae04 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
@@ -51,13 +51,17 @@ enum arua_mapped_qtypes {
 #define NIX_LF_POISON_VEC  0x82
 
 /* RSS configuration */
+struct otx2_rss_ctx {
+   u8  ind_tbl[MAX_RSS_INDIR_TBL_SIZE];
+};
+
 struct 

Re: [PATCH 07/31] serial: qcom_geni_serial: convert to use devm_pm_opp_* API

2021-01-03 Thread Viresh Kumar
On 01-01-21, 16:54, Yangtao Li wrote:
> Use devm_pm_opp_* API to simplify code, and we don't need
> to make opp_table glabal.
> 
> Let's remove opp_table from geni_se later.
> 
> Signed-off-by: Yangtao Li 
> ---
>  drivers/tty/serial/qcom_geni_serial.c | 23 +--
>  1 file changed, 9 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/tty/serial/qcom_geni_serial.c 
> b/drivers/tty/serial/qcom_geni_serial.c
> index 5aada7ebae35..36a92df8ec11 100644
> --- a/drivers/tty/serial/qcom_geni_serial.c
> +++ b/drivers/tty/serial/qcom_geni_serial.c
> @@ -1352,6 +1352,7 @@ static int qcom_geni_serial_probe(struct 
> platform_device *pdev)
>   int irq;
>   bool console = false;
>   struct uart_driver *drv;
> + struct opp_table *opp_table;
>  
>   if (of_device_is_compatible(pdev->dev.of_node, "qcom,geni-debug-uart"))
>   console = true;
> @@ -1433,13 +1434,13 @@ static int qcom_geni_serial_probe(struct 
> platform_device *pdev)
>   if (of_property_read_bool(pdev->dev.of_node, "cts-rts-swap"))
>   port->cts_rts_swap = true;
>  
> - port->se.opp_table = dev_pm_opp_set_clkname(>dev, "se");
> - if (IS_ERR(port->se.opp_table))
> - return PTR_ERR(port->se.opp_table);
> + opp_table = devm_pm_opp_set_clkname(>dev, "se");
> + if (IS_ERR(opp_table))
> + return PTR_ERR(opp_table);
>   /* OPP table is optional */
> - ret = dev_pm_opp_of_add_table(>dev);
> + ret = devm_pm_opp_of_add_table(>dev);
>   if (ret) {
> - dev_pm_opp_put_clkname(port->se.opp_table);
> + devm_pm_opp_put_clkname(>dev, opp_table);

We shouldn't be doing this here, i.e. put_clkname. Even when the OPP
table isn't present, this driver calls dev_pm_opp_set_rate() which
behaves like clk_set_rate() in this case and so the clk name is still
required by the OPP core.

>   if (ret != -ENODEV) {
>   dev_err(>dev, "invalid OPP table in device 
> tree\n");
>   return ret;
> @@ -1453,7 +1454,7 @@ static int qcom_geni_serial_probe(struct 
> platform_device *pdev)
>  
>   ret = uart_add_one_port(drv, uport);
>   if (ret)
> - goto err;
> + return ret;
>  
>   irq_set_status_flags(uport->irq, IRQ_NOAUTOEN);
>   ret = devm_request_irq(uport->dev, uport->irq, qcom_geni_serial_isr,
> @@ -1461,7 +1462,7 @@ static int qcom_geni_serial_probe(struct 
> platform_device *pdev)
>   if (ret) {
>   dev_err(uport->dev, "Failed to get IRQ ret %d\n", ret);
>   uart_remove_one_port(drv, uport);
> - goto err;
> + return ret;
>   }
>  
>   /*
> @@ -1478,15 +1479,11 @@ static int qcom_geni_serial_probe(struct 
> platform_device *pdev)
>   if (ret) {
>   device_init_wakeup(>dev, false);
>   uart_remove_one_port(drv, uport);
> - goto err;
> + return ret;
>   }
>   }
>  
>   return 0;
> -err:
> - dev_pm_opp_of_remove_table(>dev);
> - dev_pm_opp_put_clkname(port->se.opp_table);
> - return ret;
>  }
>  
>  static int qcom_geni_serial_remove(struct platform_device *pdev)
> @@ -1494,8 +1491,6 @@ static int qcom_geni_serial_remove(struct 
> platform_device *pdev)
>   struct qcom_geni_serial_port *port = platform_get_drvdata(pdev);
>   struct uart_driver *drv = port->private_data.drv;
>  
> - dev_pm_opp_of_remove_table(>dev);
> - dev_pm_opp_put_clkname(port->se.opp_table);
>   dev_pm_clear_wake_irq(>dev);
>   device_init_wakeup(>dev, false);
>   uart_remove_one_port(drv, >uport);
> -- 
> 2.25.1

-- 
viresh


Re: [PATCH 05/31] opp: Add devres wrapper for dev_pm_opp_register_notifier

2021-01-03 Thread Viresh Kumar
On 01-01-21, 16:54, Yangtao Li wrote:
> Add devres wrapper for dev_pm_opp_register_notifier() to simplify driver
> code.
> 
> Signed-off-by: Yangtao Li 
> ---
>  drivers/opp/core.c | 38 ++
>  include/linux/pm_opp.h |  6 ++
>  2 files changed, 44 insertions(+)
> 
> diff --git a/drivers/opp/core.c b/drivers/opp/core.c
> index 6b83e373f0d8..ef3544f8cecd 100644
> --- a/drivers/opp/core.c
> +++ b/drivers/opp/core.c
> @@ -2599,6 +2599,44 @@ int dev_pm_opp_unregister_notifier(struct device *dev,
>  }
>  EXPORT_SYMBOL(dev_pm_opp_unregister_notifier);
>  
> +static void devm_pm_opp_notifier_release(struct device *dev, void *res)
> +{
> + struct notifier_block *nb = *(struct notifier_block **)res;
> +
> + WARN_ON(dev_pm_opp_unregister_notifier(dev, nb));
> +}
> +
> +/**
> + * devm_pm_opp_register_notifier() - Register OPP notifier for the device
> + * @dev: Device for which notifier needs to be registered
> + * @nb:  Notifier block to be registered
> + *
> + * Return: 0 on success or a negative error value.
> + *
> + * The notifier will be unregistered after the device is destroyed.
> + */
> +int devm_pm_opp_register_notifier(struct device *dev, struct notifier_block 
> *nb)
> +{
> + struct notifier_block **ptr;
> + int ret;
> +
> + ptr = devres_alloc(devm_pm_opp_notifier_release, sizeof(*ptr), 
> GFP_KERNEL);
> + if (!ptr)
> + return -ENOMEM;
> +
> + ret = dev_pm_opp_register_notifier(dev, nb);
> + if (ret) {
> + devres_free(ptr);
> + return ret;
> + }
> +
> + *ptr = nb;
> + devres_add(dev, ptr);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(devm_pm_opp_register_notifier);

I am not in favor of this patch, and it only has one user, which makes
it more unwanted.

-- 
viresh


Re: [PATCH 1/2] clk: imx: enable the earlycon uart clocks by parsing from dt

2021-01-03 Thread Sascha Hauer
Hi Adam,

On Tue, Dec 29, 2020 at 08:51:28AM -0600, Adam Ford wrote:
> Remove the earlycon uart clocks that are hard cord in platforms
> clock driver, instead of parsing the earlycon uart port from dt

"instead parse the earlycon uart..."

Otherwise it's confusing what you mean here.

> and enable these clocks from clock property in dt node.
> 
> Fixes: 9461f7b33d11c ("clk: fix CLK_SET_RATE_GATE with clock rate protection")
> Signed-off-by: Fugang Duan 
> Signed-off-by: Adam Ford 
> ---
> Based on NXP's code base and adapted for 5.11-rc1.
> https://source.codeaurora.org/external/imx/linux-imx/commit/drivers/clk/imx/clk.c?h=imx_5.4.47_2.2.0=754ae82cc55b7445545fc2f092a70e0f490e9c1b
> 
> The original signed-off was retained.
> Added the fixes tag.
> ---
>  drivers/clk/imx/clk.c | 43 +--
>  1 file changed, 29 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
> index 47882c51cb85..c32b46890945 100644
> --- a/drivers/clk/imx/clk.c
> +++ b/drivers/clk/imx/clk.c
> @@ -148,7 +148,7 @@ void imx_cscmr1_fixup(u32 *val)
>  
>  #ifndef MODULE
>  static int imx_keep_uart_clocks;
> -static struct clk ** const *imx_uart_clocks;
> +static bool imx_uart_clks_on;
>  
>  static int __init imx_keep_uart_clocks_param(char *str)
>  {
> @@ -161,25 +161,40 @@ __setup_param("earlycon", imx_keep_uart_earlycon,
>  __setup_param("earlyprintk", imx_keep_uart_earlyprintk,
> imx_keep_uart_clocks_param, 0);
>  
> -void imx_register_uart_clocks(struct clk ** const clks[])
> +static void imx_earlycon_uart_clks_onoff(bool is_on)

"is_on" sounds like it's the current state of the clock, but actually
the variable is used for the desired state, so I suggest using plain
"on" as name.

>  {
> - if (imx_keep_uart_clocks) {
> - int i;
> + struct clk *uart_clk;
> + int i = 0;
>  
> - imx_uart_clocks = clks;
> - for (i = 0; imx_uart_clocks[i]; i++)
> - clk_prepare_enable(*imx_uart_clocks[i]);
> - }
> + if (!imx_keep_uart_clocks || (!is_on && !imx_uart_clks_on))
> + return;
> +
> + /* only support dt */
> + if (!of_stdout)
> + return;
> +
> + do {
> + uart_clk = of_clk_get(of_stdout, i++);

of_clk_get() allocates memory and gets you a reference to the clock. You
have to release the clock with clk_put(). I think what you have to do
here is to fill an array with clks when called from
imx_register_uart_clocks() and when called from imx_clk_disable_uart()
use that array to clk_disable_unprepare()/clk_put() the clocks.

Sascha

> + if (IS_ERR(uart_clk))
> + break;
> +
> + if (is_on)
> + clk_prepare_enable(uart_clk);
> + else
> + clk_disable_unprepare(uart_clk);
> + } while (true);
> +
> + if (is_on)
> + imx_uart_clks_on = true;
> +}
> +void imx_register_uart_clocks(struct clk ** const clks[])
> +{
> + imx_earlycon_uart_clks_onoff(true);
>  }
>  
>  static int __init imx_clk_disable_uart(void)
>  {
> - if (imx_keep_uart_clocks && imx_uart_clocks) {
> - int i;
> -
> - for (i = 0; imx_uart_clocks[i]; i++)
> - clk_disable_unprepare(*imx_uart_clocks[i]);
> - }
> + imx_earlycon_uart_clks_onoff(false);
>  
>   return 0;
>  }
> -- 
> 2.25.1
> 
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


[PATCH v1 1/2] dt-bindings: Convert Arm Mali Valhall GPU to DT schema

2021-01-03 Thread Nick Fan
Convert the Arm Valhall GPU binding to DT schema format.

Define a compatible string for the Mali Valhall GPU
for Mediatek's SoC platform.

Signed-off-by: Nick Fan 
---
 .../bindings/gpu/arm,mali-valhall.yaml| 252 ++
 1 file changed, 252 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpu/arm,mali-valhall.yaml

diff --git a/Documentation/devicetree/bindings/gpu/arm,mali-valhall.yaml 
b/Documentation/devicetree/bindings/gpu/arm,mali-valhall.yaml
new file mode 100644
index ..436294c032ff
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpu/arm,mali-valhall.yaml
@@ -0,0 +1,252 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (c) 2020 MediaTek Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/gpu/arm,mali-valhall.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ARM Mali Valhall GPU
+
+maintainers:
+  - Rob Herring 
+
+properties:
+  $nodename:
+pattern: '^gpu@[a-f0-9]+$'
+
+  compatible:
+items:
+  - enum:
+  - mediatek,mt8192-mali
+  - const: arm,mali-valhall
+
+  reg:
+maxItems: 1
+
+  interrupts:
+items:
+  - description: GPU interrupt
+  - description: MMU interrupt
+  - description: Job interrupt
+
+  interrupt-names:
+items:
+  - const: gpu
+  - const: mmu
+  - const: job
+
+  clocks:
+minItems: 1
+
+  power-domains:
+minItems: 1
+maxItems: 5
+
+  mali-supply: true
+  sram-supply: true
+
+  operating-points-v2: true
+
+  "#cooling-cells":
+const: 2
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-names
+  - clocks
+
+additionalProperties: false
+
+allOf:
+  - if:
+  properties:
+compatible:
+  contains:
+const: mediatek,mt8192-mali
+then:
+  properties:
+sram-supply: true
+power-domains:
+  description:
+List of phandle and PM domain specifier as documented in
+Documentation/devicetree/bindings/power/power_domain.txt
+  minItems: 5
+  maxItems: 5
+power-domain-names:
+  items:
+- const: core0
+- const: core1
+- const: core2
+- const: core3
+- const: core4
+
+  required:
+- sram-supply
+- power-domains
+
+examples:
+  - |
+#include 
+#include 
+
+gpu@1300 {
+   compatible = "mediatek,mt8192-mali", "arm,mali-valhall";
+   reg = <0x1300 0x4000>;
+   interrupts =
+   ,
+   ,
+   ;
+   interrupt-names =
+   "gpu",
+   "mmu",
+   "job";
+
+   clocks = < 0>;
+
+   power-domains =
+   < 4>,
+   < 5>,
+   < 6>,
+   < 7>,
+   < 8>;
+
+   operating-points-v2 = <_opp_table>;
+   mali-supply = <_7_vbuck1>;
+   sram-supply = <_vsram_others_ldo_reg>;
+};
+
+gpu_opp_table: opp_table0 {
+  compatible = "operating-points-v2";
+  opp-shared;
+
+  opp-35800 {
+  opp-hz = /bits/ 64 <35800>;
+  opp-hz-real = /bits/ 64 <35800>,
+/bits/ 64 <35800>;
+  opp-microvolt = <606250>,
+  <75>;
+  };
+
+  opp-39900 {
+  opp-hz = /bits/ 64 <39900>;
+  opp-hz-real = /bits/ 64 <39900>,
+/bits/ 64 <39900>;
+  opp-microvolt = <618750>,
+  <75>;
+  };
+
+  opp-44000 {
+  opp-hz = /bits/ 64 <44000>;
+  opp-hz-real = /bits/ 64 <44000>,
+/bits/ 64 <44000>;
+  opp-microvolt = <631250>,
+  <75>;
+  };
+
+  opp-48200 {
+  opp-hz = /bits/ 64 <48200>;
+  opp-hz-real = /bits/ 64 <48200>,
+/bits/ 64 <48200>;
+  opp-microvolt = <643750>,
+  <75>;
+  };
+
+  opp-52300 {
+  opp-hz = /bits/ 64 <52300>;
+  opp-hz-real = /bits/ 64 <52300>,
+/bits/ 64 <52300>;
+  opp-microvolt = <656250>,
+  <75>;
+  };
+
+  opp-56400 {
+  opp-hz = /bits/ 64 <56400>;
+  opp-hz-real = /bits/ 64 <56400>,
+/bits/ 64 <56400>;
+  opp-microvolt = <668750>,
+  <75>;
+  };
+
+  opp-60500 {
+  opp-hz = /bits/ 64 <60500>;
+  opp-hz-real = /bits/ 64 <60500>,
+/bits/ 64 <60500>;
+  opp-microvolt = <681250>,
+   

[PATCH v1 2/2] arm64: dts: mt8192: Add node for the Mali GPU

2021-01-03 Thread Nick Fan
Add a basic GPU node for mt8192.

Signed-off-by: Nick Fan 
---
This patch depends on Mediatek power and regulator support.

Listed as following.

[1]https://lore.kernel.org/patchwork/patch/1336293/
[2]https://patchwork.kernel.org/project/linux-mediatek/list/?series=374013
[3]https://lore.kernel.org/patchwork/patch/1356037/
[4]https://patchwork.kernel.org/project/linux-mediatek/list/?series=405777
[5]https://lore.kernel.org/patchwork/patch/1356175/
[6]https://patchwork.kernel.org/project/linux-mediatek/patch/1605700894-32699-6-git-send-email-hsin-hsiung.w...@mediatek.com/
[7]https://patchwork.kernel.org/project/linux-mediatek/patch/1608104827-7937-10-git-send-email-hsin-hsiung.w...@mediatek.com/
---
---
 arch/arm64/boot/dts/mediatek/mt8192-evb.dts |   7 +
 arch/arm64/boot/dts/mediatek/mt8192.dtsi| 176 
 2 files changed, 183 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8192-evb.dts 
b/arch/arm64/boot/dts/mediatek/mt8192-evb.dts
index 6c1e2b3e8a60..48c0e240dd92 100644
--- a/arch/arm64/boot/dts/mediatek/mt8192-evb.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8192-evb.dts
@@ -5,6 +5,7 @@
  */
 /dts-v1/;
 #include "mt8192.dtsi"
+#include "mt6359.dtsi"
 
 / {
model = "MediaTek MT8192 evaluation board";
@@ -70,6 +71,12 @@
};
 };
 
+ {
+   supply-names = "mali","sram";
+   mali-supply = <_7_vbuck1>;
+   sram-supply = <_vsram_others_ldo_reg>;
+};
+
  {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/mediatek/mt8192.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
index d6a4ad242a33..de166ea750af 100644
--- a/arch/arm64/boot/dts/mediatek/mt8192.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
@@ -822,6 +822,182 @@
#clock-cells = <1>;
};
 
+   gpu: mali@1300 {
+   compatible = "mediatek,mt8192-mali", "arm,mali-valhall";
+   reg = <0 0x1300 0 0x4000>;
+   interrupts =
+   ,
+   ,
+   ,
+   ,
+   ;
+   interrupt-names =
+   "GPU",
+   "MMU",
+   "JOB",
+   "EVENT",
+   "PWR";
+
+   clocks =
+   < CLK_APMIXED_MFGPLL>,
+   < CLK_TOP_MFG_PLL_SEL>,
+   < CLK_TOP_MFG_REF_SEL>,
+   < CLK_MFG_BG3D>;
+   clock-names =
+   "clk_main_parent",
+   "clk_mux",
+   "clk_sub_parent",
+   "subsys_mfg_cg";
+
+   power-domains =
+   < MT8192_POWER_DOMAIN_MFG2>,
+   < MT8192_POWER_DOMAIN_MFG3>,
+   < MT8192_POWER_DOMAIN_MFG4>,
+   < MT8192_POWER_DOMAIN_MFG5>,
+   < MT8192_POWER_DOMAIN_MFG6>;
+   power-domain-names = "core0",
+"core1",
+"core2",
+"core3",
+"core4";
+
+   operating-points-v2 = <_opp_table>;
+   #cooling-cells = <2>;
+   };
+
+   gpu_opp_table: opp_table0 {
+   compatible = "operating-points-v2";
+   opp-shared;
+
+   opp-35800 {
+   opp-hz = /bits/ 64 <35800>;
+   opp-hz-real = /bits/ 64 <35800>,
+ /bits/ 64 <35800>;
+   opp-microvolt = <606250>,
+   <75>;
+   };
+
+   opp-39900 {
+   opp-hz = /bits/ 64 <39900>;
+   opp-hz-real = /bits/ 64 <39900>,
+ /bits/ 64 <39900>;
+   opp-microvolt = <618750>,
+   <75>;
+   };
+
+   opp-44000 {
+   opp-hz = /bits/ 64 <44000>;
+   opp-hz-real = /bits/ 64 <44000>,
+ /bits/ 64 <44000>;
+   opp-microvolt = <631250>,
+   <75>;
+   };
+
+   opp-48200 {
+   

[PATCH 6/6] mm: hugetlb: remove VM_BUG_ON_PAGE from page_huge_active

2021-01-03 Thread Muchun Song
The page_huge_active() can be called from scan_movable_pages() which
do not hold a reference count to the HugeTLB page. So when we call
page_huge_active() from scan_movable_pages(), the HugeTLB page can
be freed parallel. Then we will trigger a BUG_ON which is in the
page_huge_active() when CONFIG_DEBUG_VM is enabled. Just remove the
VM_BUG_ON_PAGE.

Fixes: 7e1f049efb86 ("mm: hugetlb: cleanup using paeg_huge_active()")
Signed-off-by: Muchun Song 
---
 mm/hugetlb.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 5c2f64f53177..4c8631114e88 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1360,7 +1360,6 @@ struct hstate *size_to_hstate(unsigned long size)
  */
 bool page_huge_active(struct page *page)
 {
-   VM_BUG_ON_PAGE(!PageHuge(page), page);
return PageHead(page) && PagePrivate([1]);
 }
 
-- 
2.11.0



[PATCH 4/6] mm: hugetlb: add return -EAGAIN for dissolve_free_huge_page

2021-01-03 Thread Muchun Song
When dissolve_free_huge_page() races with __free_huge_page(), we can
do a retry. Because the race window is small.

Signed-off-by: Muchun Song 
---
 mm/hugetlb.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 72608008f8b4..db00ae375d2a 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1763,10 +1763,11 @@ static int free_pool_huge_page(struct hstate *h, 
nodemask_t *nodes_allowed,
  * nothing for in-use hugepages and non-hugepages.
  * This function returns values like below:
  *
- *  -EBUSY: failed to dissolved free hugepages or the hugepage is in-use
- *  (allocated or reserved.)
- *   0: successfully dissolved free hugepages or the page is not a
- *  hugepage (considered as already dissolved)
+ *  -EAGAIN: race with __free_huge_page() and can do a retry
+ *  -EBUSY:  failed to dissolved free hugepages or the hugepage is in-use
+ *   (allocated or reserved.)
+ *   0:  successfully dissolved free hugepages or the page is not a
+ *   hugepage (considered as already dissolved)
  */
 int dissolve_free_huge_page(struct page *page)
 {
@@ -1815,8 +1816,10 @@ int dissolve_free_huge_page(struct page *page)
 * We should make sure that the page is already on the free list
 * when it is dissolved.
 */
-   if (unlikely(!PageHugeFreed(head)))
+   if (unlikely(!PageHugeFreed(head))) {
+   rc = -EAGAIN;
goto out;
+   }
 
/*
 * Move PageHWPoison flag from head page to the raw error page,
@@ -1857,7 +1860,10 @@ int dissolve_free_huge_pages(unsigned long start_pfn, 
unsigned long end_pfn)
 
for (pfn = start_pfn; pfn < end_pfn; pfn += 1 << minimum_order) {
page = pfn_to_page(pfn);
+retry:
rc = dissolve_free_huge_page(page);
+   if (rc == -EAGAIN)
+   goto retry;
if (rc)
break;
}
-- 
2.11.0



[PATCH 5/6] mm: hugetlb: fix a race between isolating and freeing page

2021-01-03 Thread Muchun Song
There is a race between isolate_huge_page() and __free_huge_page().

CPU0:   CPU1:

if (PageHuge(page))
put_page(page)
  __free_huge_page(page)
  spin_lock(_lock)
  update_and_free_page(page)
set_compound_page_dtor(page,
  NULL_COMPOUND_DTOR)
  spin_unlock(_lock)
  isolate_huge_page(page)
// trigger BUG_ON
VM_BUG_ON_PAGE(!PageHead(page), page)
spin_lock(_lock)
page_huge_active(page)
  // trigger BUG_ON
  VM_BUG_ON_PAGE(!PageHuge(page), page)
spin_unlock(_lock)

When we isolate a HugeTLB page on CPU0. Meanwhile, we free it to the
buddy allocator on CPU1. Then, we can trigger a BUG_ON on CPU0. Because
it is already freed to the buddy allocator.

Fixes: c8721bbbdd36 ("mm: memory-hotplug: enable memory hotplug to handle 
hugepage")
Signed-off-by: Muchun Song 
---
 mm/hugetlb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index db00ae375d2a..5c2f64f53177 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5587,9 +5587,9 @@ bool isolate_huge_page(struct page *page, struct 
list_head *list)
 {
bool ret = true;
 
-   VM_BUG_ON_PAGE(!PageHead(page), page);
spin_lock(_lock);
-   if (!page_huge_active(page) || !get_page_unless_zero(page)) {
+   if (!PageHeadHuge(page) || !page_huge_active(page) ||
+   !get_page_unless_zero(page)) {
ret = false;
goto unlock;
}
-- 
2.11.0



Re: [PATCH 06/31] serial: qcom_geni_serial: fix potential mem leak in qcom_geni_serial_probe()

2021-01-03 Thread Viresh Kumar
On 01-01-21, 16:54, Yangtao Li wrote:
> We should use dev_pm_opp_put_clkname() to free opp table each time
> dev_pm_opp_of_add_table() got error.
> 
> Signed-off-by: Yangtao Li 
> ---
>  drivers/tty/serial/qcom_geni_serial.c | 10 ++
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/qcom_geni_serial.c 
> b/drivers/tty/serial/qcom_geni_serial.c
> index 291649f02821..5aada7ebae35 100644
> --- a/drivers/tty/serial/qcom_geni_serial.c
> +++ b/drivers/tty/serial/qcom_geni_serial.c
> @@ -1438,9 +1438,12 @@ static int qcom_geni_serial_probe(struct 
> platform_device *pdev)
>   return PTR_ERR(port->se.opp_table);
>   /* OPP table is optional */
>   ret = dev_pm_opp_of_add_table(>dev);
> - if (ret && ret != -ENODEV) {
> - dev_err(>dev, "invalid OPP table in device tree\n");
> - goto put_clkname;
> + if (ret) {
> + dev_pm_opp_put_clkname(port->se.opp_table);
> + if (ret != -ENODEV) {
> + dev_err(>dev, "invalid OPP table in device 
> tree\n");
> + return ret;
> + }
>   }
>  
>   port->private_data.drv = drv;
> @@ -1482,7 +1485,6 @@ static int qcom_geni_serial_probe(struct 
> platform_device *pdev)
>   return 0;
>  err:
>   dev_pm_opp_of_remove_table(>dev);
> -put_clkname:
>   dev_pm_opp_put_clkname(port->se.opp_table);
>   return ret;
>  }

Since put_clkname is always done in remove(), I don't think there is
any memleak here. Over that with your patch we will do put_clkname
twice now, once in probe and once in remove. And that is a bug AFAICT.

-- 
viresh


[PATCH 3/6] mm: hugetlb: fix a race between freeing and dissolving the page

2021-01-03 Thread Muchun Song
There is a race condition between __free_huge_page()
and dissolve_free_huge_page().

CPU0: CPU1:

// page_count(page) == 1
put_page(page)
  __free_huge_page(page)
  dissolve_free_huge_page(page)
spin_lock(_lock)
// PageHuge(page) && !page_count(page)
update_and_free_page(page)
// page is freed to the buddy
spin_unlock(_lock)
spin_lock(_lock)
clear_page_huge_active(page)
enqueue_huge_page(page)
// It is wrong, the page is already freed
spin_unlock(_lock)

The race windows is between put_page() and spin_lock() which
is in the __free_huge_page().

We should make sure that the page is already on the free list
when it is dissolved.

Fixes: c8721bbbdd36 ("mm: memory-hotplug: enable memory hotplug to handle 
hugepage")
Signed-off-by: Muchun Song 
---
 mm/hugetlb.c | 48 
 1 file changed, 48 insertions(+)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 1f3bf1710b66..72608008f8b4 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -79,6 +79,21 @@ DEFINE_SPINLOCK(hugetlb_lock);
 static int num_fault_mutexes;
 struct mutex *hugetlb_fault_mutex_table cacheline_aligned_in_smp;
 
+static inline bool PageHugeFreed(struct page *head)
+{
+   return page_private(head) == -1UL;
+}
+
+static inline void SetPageHugeFreed(struct page *head)
+{
+   set_page_private(head + 4, -1UL);
+}
+
+static inline void ClearPageHugeFreed(struct page *head)
+{
+   set_page_private(head + 4, 0);
+}
+
 /* Forward declaration */
 static int hugetlb_acct_memory(struct hstate *h, long delta);
 
@@ -1028,6 +1043,7 @@ static void enqueue_huge_page(struct hstate *h, struct 
page *page)
list_move(>lru, >hugepage_freelists[nid]);
h->free_huge_pages++;
h->free_huge_pages_node[nid]++;
+   SetPageHugeFreed(page);
 }
 
 static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid)
@@ -1044,6 +1060,7 @@ static struct page *dequeue_huge_page_node_exact(struct 
hstate *h, int nid)
 
list_move(>lru, >hugepage_activelist);
set_page_refcounted(page);
+   ClearPageHugeFreed(page);
h->free_huge_pages--;
h->free_huge_pages_node[nid]--;
return page;
@@ -1504,6 +1521,7 @@ static void prep_new_huge_page(struct hstate *h, struct 
page *page, int nid)
spin_lock(_lock);
h->nr_huge_pages++;
h->nr_huge_pages_node[nid]++;
+   ClearPageHugeFreed(page);
spin_unlock(_lock);
 }
 
@@ -1770,6 +1788,36 @@ int dissolve_free_huge_page(struct page *page)
int nid = page_to_nid(head);
if (h->free_huge_pages - h->resv_huge_pages == 0)
goto out;
+
+   /*
+* There is a race condition between __free_huge_page()
+* and dissolve_free_huge_page().
+*
+* CPU0: CPU1:
+*
+* // page_count(page) == 1
+* put_page(page)
+*   __free_huge_page(page)
+*   dissolve_free_huge_page(page)
+* spin_lock(_lock)
+* // PageHuge(page) && 
!page_count(page)
+* update_and_free_page(page)
+* // page is freed to the buddy
+* spin_unlock(_lock)
+* spin_lock(_lock)
+* enqueue_huge_page(page)
+* // It is wrong, the page is already freed
+* spin_unlock(_lock)
+*
+* The race window is between put_page() and spin_lock() which
+* is in the __free_huge_page().
+*
+* We should make sure that the page is already on the free list
+* when it is dissolved.
+*/
+   if (unlikely(!PageHugeFreed(head)))
+   goto out;
+
/*
 * Move PageHWPoison flag from head page to the raw error page,
 * which makes any subpages rather than the error page reusable.
-- 
2.11.0



[PATCH 2/6] hugetlbfs: fix cannot migrate the fallocated HugeTLB page

2021-01-03 Thread Muchun Song
Because we only can isolate a active page via isolate_huge_page()
and hugetlbfs_fallocate() forget to mark it as active, we cannot
isolate and migrate those pages.

Fixes: 70c3547e36f5 (hugetlbfs: add hugetlbfs_fallocate())
Signed-off-by: Muchun Song 
---
 fs/hugetlbfs/inode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index b5c109703daa..2aceb085d202 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -737,10 +737,11 @@ static long hugetlbfs_fallocate(struct file *file, int 
mode, loff_t offset,
 
/*
 * unlock_page because locked by add_to_page_cache()
-* page_put due to reference from alloc_huge_page()
+* put_page() (which is in the putback_active_hugepage())
+* due to reference from alloc_huge_page()
 */
unlock_page(page);
-   put_page(page);
+   putback_active_hugepage(page);
}
 
if (!(mode & FALLOC_FL_KEEP_SIZE) && offset + len > inode->i_size)
-- 
2.11.0



[PATCH 1/6] mm: migrate: do not migrate HugeTLB page whose refcount is one

2021-01-03 Thread Muchun Song
If the refcount is one when it is migrated, it means that the page
was freed from under us. So we are done and do not need to migrate.

Signed-off-by: Muchun Song 
---
 mm/migrate.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/mm/migrate.c b/mm/migrate.c
index 4385f2fb5d18..a6631c4eb6a6 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1279,6 +1279,12 @@ static int unmap_and_move_huge_page(new_page_t 
get_new_page,
return -ENOSYS;
}
 
+   if (page_count(hpage) == 1) {
+   /* page was freed from under us. So we are done. */
+   putback_active_hugepage(hpage);
+   return MIGRATEPAGE_SUCCESS;
+   }
+
new_hpage = get_new_page(hpage, private);
if (!new_hpage)
return -ENOMEM;
-- 
2.11.0



Re: [PATCH V2 00/19] vDPA driver for virtio-pci device

2021-01-03 Thread Jason Wang



On 2021/1/3 下午8:37, Michael S. Tsirkin wrote:

On Thu, Dec 31, 2020 at 11:52:14AM +0800, Jason Wang wrote:

On 2020/12/4 下午12:03, Jason Wang wrote:

Hi all:

This series tries to implement a vDPA driver for virtio-pci device
which will bridge between vDPA bus and virtio-pci device.

This could be used for future feature prototyping and testing.

Please review

Changes from V2:

- don't try to use devres for virtio-pci core
- tweak the commit log
- split the patches furtherly to ease the reviewing

Changes from V1:

- Split common codes from virito-pci and share it with vDPA driver
- Use dynamic id in order to be less confusing with virtio-pci driver
- No feature whitelist, supporting any features (mq, config etc)

Thanks


Michael, any comment for this series?

It's needed for testing doorbell mapping and config interrupt support.

Thanks

I saw you got some comments back in december so was expecting another
version. If you'd rather I reviewed this one, let me know.



Right. So I've posted a new version that tries to address the previous 
comments.


Please review that version.

Thanks








[PATCH V3 16/19] virtio-pci: introduce modern device module

2021-01-03 Thread Jason Wang
Signed-off-by: Jason Wang 
---
 drivers/virtio/Kconfig |  10 +-
 drivers/virtio/Makefile|   1 +
 drivers/virtio/virtio_pci_common.h |  27 +-
 drivers/virtio/virtio_pci_modern.c | 617 -
 drivers/virtio/virtio_pci_modern_dev.c | 599 
 include/linux/virtio_pci_modern.h  | 111 +
 6 files changed, 721 insertions(+), 644 deletions(-)
 create mode 100644 drivers/virtio/virtio_pci_modern_dev.c
 create mode 100644 include/linux/virtio_pci_modern.h

diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
index 7b41130d3f35..6b9b81f4b8c2 100644
--- a/drivers/virtio/Kconfig
+++ b/drivers/virtio/Kconfig
@@ -12,6 +12,14 @@ config ARCH_HAS_RESTRICTED_VIRTIO_MEMORY_ACCESS
  This option is selected if the architecture may need to enforce
  VIRTIO_F_ACCESS_PLATFORM
 
+config VIRTIO_PCI_MODERN
+   tristate "Modern Virtio PCI Device"
+   depends on PCI
+   help
+ Modern PCI device implementation. This module implements the
+ basic probe and control for devices which are based on modern
+ PCI device with possible vendor specific extensions.
+
 menuconfig VIRTIO_MENU
bool "Virtio drivers"
default y
@@ -20,7 +28,7 @@ if VIRTIO_MENU
 
 config VIRTIO_PCI
tristate "PCI driver for virtio devices"
-   depends on PCI
+   depends on VIRTIO_PCI_MODERN
select VIRTIO
help
  This driver provides support for virtio based paravirtual device
diff --git a/drivers/virtio/Makefile b/drivers/virtio/Makefile
index 591e6f72aa54..f097578aaa8f 100644
--- a/drivers/virtio/Makefile
+++ b/drivers/virtio/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_VIRTIO) += virtio.o virtio_ring.o
+obj-$(CONFIG_VIRTIO_PCI_MODERN) += virtio_pci_modern_dev.o
 obj-$(CONFIG_VIRTIO_MMIO) += virtio_mmio.o
 obj-$(CONFIG_VIRTIO_PCI) += virtio_pci.o
 virtio_pci-y := virtio_pci_modern.o virtio_pci_common.o
diff --git a/drivers/virtio/virtio_pci_common.h 
b/drivers/virtio/virtio_pci_common.h
index f35ff5b6b467..beec047a8f8d 100644
--- a/drivers/virtio/virtio_pci_common.h
+++ b/drivers/virtio/virtio_pci_common.h
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -39,32 +40,6 @@ struct virtio_pci_vq_info {
unsigned msix_vector;
 };
 
-struct virtio_pci_modern_device {
-   struct pci_dev *pci_dev;
-
-   struct virtio_pci_common_cfg __iomem *common;
-   /* Device-specific data (non-legacy mode)  */
-   void __iomem *device;
-   /* Base of vq notifications (non-legacy mode). */
-   void __iomem *notify_base;
-   /* Where to read and clear interrupt */
-   u8 __iomem *isr;
-
-   /* So we can sanity-check accesses. */
-   size_t notify_len;
-   size_t device_len;
-
-   /* Capability for when we need to map notifications per-vq. */
-   int notify_map_cap;
-
-   /* Multiply queue_notify_off by this value. (non-legacy mode). */
-   u32 notify_offset_multiplier;
-
-   int modern_bars;
-
-   struct virtio_device_id id;
-};
-
 /* Our device structure */
 struct virtio_pci_device {
struct virtio_device vdev;
diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index a5e3a5e40323..fbd4ebc00eb6 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -19,158 +19,6 @@
 #define VIRTIO_RING_NO_LEGACY
 #include "virtio_pci_common.h"
 
-/*
- * Type-safe wrappers for io accesses.
- * Use these to enforce at compile time the following spec requirement:
- *
- * The driver MUST access each field using the “natural” access
- * method, i.e. 32-bit accesses for 32-bit fields, 16-bit accesses
- * for 16-bit fields and 8-bit accesses for 8-bit fields.
- */
-static inline u8 vp_ioread8(const u8 __iomem *addr)
-{
-   return ioread8(addr);
-}
-static inline u16 vp_ioread16 (const __le16 __iomem *addr)
-{
-   return ioread16(addr);
-}
-
-static inline u32 vp_ioread32(const __le32 __iomem *addr)
-{
-   return ioread32(addr);
-}
-
-static inline void vp_iowrite8(u8 value, u8 __iomem *addr)
-{
-   iowrite8(value, addr);
-}
-
-static inline void vp_iowrite16(u16 value, __le16 __iomem *addr)
-{
-   iowrite16(value, addr);
-}
-
-static inline void vp_iowrite32(u32 value, __le32 __iomem *addr)
-{
-   iowrite32(value, addr);
-}
-
-static void vp_iowrite64_twopart(u64 val,
-__le32 __iomem *lo, __le32 __iomem *hi)
-{
-   vp_iowrite32((u32)val, lo);
-   vp_iowrite32(val >> 32, hi);
-}
-
-/*
- * vp_modern_map_capability - map a part of virtio pci capability
- * @mdev: the modern virtio-pci device
- * @off: offset of the capability
- * @minlen: minimal length of the capability
- * @align: align requirement
- * @start: start from the capability
- * @size: map size
- * @len: the length that is actually mapped
- *
- * Returns the io address of 

[PATCH V3 19/19] vdpa: introduce virtio pci driver

2021-01-03 Thread Jason Wang
This patch introduce a vDPA driver for virtio-pci device. It bridges
the virtio-pci control command to the vDPA bus. This will be used for
features prototyping and testing.

Note that get/restore virtqueue state is not supported which needs
extension on the virtio specification.

Signed-off-by: Jason Wang 
---
 drivers/vdpa/Kconfig  |   6 +
 drivers/vdpa/Makefile |   1 +
 drivers/vdpa/virtio_pci/Makefile  |   2 +
 drivers/vdpa/virtio_pci/vp_vdpa.c | 456 ++
 4 files changed, 465 insertions(+)
 create mode 100644 drivers/vdpa/virtio_pci/Makefile
 create mode 100644 drivers/vdpa/virtio_pci/vp_vdpa.c

diff --git a/drivers/vdpa/Kconfig b/drivers/vdpa/Kconfig
index 6caf539091e5..81c6a3520813 100644
--- a/drivers/vdpa/Kconfig
+++ b/drivers/vdpa/Kconfig
@@ -49,4 +49,10 @@ config MLX5_VDPA_NET
  be executed by the hardware. It also supports a variety of stateless
  offloads depending on the actual device used and firmware version.
 
+config VP_VDPA
+   tristate "Virtio PCI bridge vDPA driver"
+   depends on PCI_MSI && VIRTIO_PCI_MODERN
+   help
+ This kernel module bridges virtio PCI device to vDPA bus.
+
 endif # VDPA
diff --git a/drivers/vdpa/Makefile b/drivers/vdpa/Makefile
index d160e9b63a66..67fe7f3d6943 100644
--- a/drivers/vdpa/Makefile
+++ b/drivers/vdpa/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_VDPA) += vdpa.o
 obj-$(CONFIG_VDPA_SIM) += vdpa_sim/
 obj-$(CONFIG_IFCVF)+= ifcvf/
 obj-$(CONFIG_MLX5_VDPA) += mlx5/
+obj-$(CONFIG_VP_VDPA)+= virtio_pci/
diff --git a/drivers/vdpa/virtio_pci/Makefile b/drivers/vdpa/virtio_pci/Makefile
new file mode 100644
index ..231088d3af7d
--- /dev/null
+++ b/drivers/vdpa/virtio_pci/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_VP_VDPA) += vp_vdpa.o
diff --git a/drivers/vdpa/virtio_pci/vp_vdpa.c 
b/drivers/vdpa/virtio_pci/vp_vdpa.c
new file mode 100644
index ..4eda926493d9
--- /dev/null
+++ b/drivers/vdpa/virtio_pci/vp_vdpa.c
@@ -0,0 +1,456 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * vDPA bridge driver for modern virtio-pci device
+ *
+ * Copyright (c) 2020, Red Hat Inc. All rights reserved.
+ * Author: Jason Wang 
+ *
+ * Based on virtio_pci_modern.c.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define VP_VDPA_QUEUE_MAX 256
+#define VP_VDPA_DRIVER_NAME "vp_vdpa"
+#define VP_VDPA_NAME_SIZE 256
+
+struct vp_vring {
+   void __iomem *notify;
+   char msix_name[VP_VDPA_NAME_SIZE];
+   struct vdpa_callback cb;
+   int irq;
+};
+
+struct vp_vdpa {
+   struct vdpa_device vdpa;
+   struct virtio_pci_modern_device mdev;
+   struct vp_vring *vring;
+   struct vdpa_callback config_cb;
+   char msix_name[VP_VDPA_NAME_SIZE];
+   int config_irq;
+   int queues;
+   int vectors;
+};
+
+static struct vp_vdpa *vdpa_to_vp(struct vdpa_device *vdpa)
+{
+   return container_of(vdpa, struct vp_vdpa, vdpa);
+}
+
+static struct virtio_pci_modern_device *vdpa_to_mdev(struct vdpa_device *vdpa)
+{
+   struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa);
+
+   return _vdpa->mdev;
+}
+
+static u64 vp_vdpa_get_features(struct vdpa_device *vdpa)
+{
+   struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
+
+   return vp_modern_get_features(mdev);
+}
+
+static int vp_vdpa_set_features(struct vdpa_device *vdpa, u64 features)
+{
+   struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
+
+   vp_modern_set_features(mdev, features);
+
+   return 0;
+}
+
+static u8 vp_vdpa_get_status(struct vdpa_device *vdpa)
+{
+   struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
+
+   return vp_modern_get_status(mdev);
+}
+
+static void vp_vdpa_free_irq(struct vp_vdpa *vp_vdpa)
+{
+   struct virtio_pci_modern_device *mdev = _vdpa->mdev;
+   struct pci_dev *pdev = mdev->pci_dev;
+   int i;
+
+   for (i = 0; i < vp_vdpa->queues; i++) {
+   if (vp_vdpa->vring[i].irq != VIRTIO_MSI_NO_VECTOR) {
+   vp_modern_queue_vector(mdev, i, VIRTIO_MSI_NO_VECTOR);
+   devm_free_irq(>dev, vp_vdpa->vring[i].irq,
+ _vdpa->vring[i]);
+   vp_vdpa->vring[i].irq = VIRTIO_MSI_NO_VECTOR;
+   }
+   }
+
+   if (vp_vdpa->config_irq != VIRTIO_MSI_NO_VECTOR) {
+   vp_modern_config_vector(mdev, VIRTIO_MSI_NO_VECTOR);
+   devm_free_irq(>dev, vp_vdpa->config_irq, vp_vdpa);
+   vp_vdpa->config_irq = VIRTIO_MSI_NO_VECTOR;
+   }
+
+   if (vp_vdpa->vectors) {
+   pci_free_irq_vectors(pdev);
+   vp_vdpa->vectors = 0;
+   }
+}
+
+static irqreturn_t vp_vdpa_vq_handler(int irq, void *arg)
+{
+   struct vp_vring *vring = arg;
+
+   if (vring->cb.callback)
+   return vring->cb.callback(vring->cb.private);
+
+   return 

[PATCH V3 18/19] virtio_vdpa: don't warn when fail to disable vq

2021-01-03 Thread Jason Wang
There's no guarantee that the device can disable a specific virtqueue
through set_vq_ready(). One example is the modern virtio-pci
device. So this patch removes the warning.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_vdpa.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
index 4a9ddb44b2a7..e28acf482e0c 100644
--- a/drivers/virtio/virtio_vdpa.c
+++ b/drivers/virtio/virtio_vdpa.c
@@ -225,9 +225,8 @@ static void virtio_vdpa_del_vq(struct virtqueue *vq)
list_del(>node);
spin_unlock_irqrestore(_dev->lock, flags);
 
-   /* Select and deactivate the queue */
+   /* Select and deactivate the queue (best effort) */
ops->set_vq_ready(vdpa, index, 0);
-   WARN_ON(ops->get_vq_ready(vdpa, index));
 
vring_del_virtqueue(vq);
 
-- 
2.25.1



[PATCH V3 15/19] virito-pci-modern: rename map_capability() to vp_modern_map_capability()

2021-01-03 Thread Jason Wang
To ease the split, map_capability() was renamed to
vp_modern_map_capability(). While at it, add the comments for the
arguments and switch to use virtio_pci_modern_device as the first
parameter.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_modern.c | 46 +++---
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index 217573f2588d..a5e3a5e40323 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -63,12 +63,25 @@ static void vp_iowrite64_twopart(u64 val,
vp_iowrite32(val >> 32, hi);
 }
 
-static void __iomem *map_capability(struct pci_dev *dev, int off,
-   size_t minlen,
-   u32 align,
-   u32 start, u32 size,
-   size_t *len)
+/*
+ * vp_modern_map_capability - map a part of virtio pci capability
+ * @mdev: the modern virtio-pci device
+ * @off: offset of the capability
+ * @minlen: minimal length of the capability
+ * @align: align requirement
+ * @start: start from the capability
+ * @size: map size
+ * @len: the length that is actually mapped
+ *
+ * Returns the io address of for the part of the capability
+ */
+void __iomem *vp_modern_map_capability(struct virtio_pci_modern_device *mdev, 
int off,
+  size_t minlen,
+  u32 align,
+  u32 start, u32 size,
+  size_t *len)
 {
+   struct pci_dev *dev = mdev->pci_dev;
u8 bar;
u32 offset, length;
void __iomem *p;
@@ -582,7 +595,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device 
*vp_dev,
vq->priv = (void __force *)mdev->notify_base +
off * mdev->notify_offset_multiplier;
} else {
-   vq->priv = (void __force *)map_capability(mdev->pci_dev,
+   vq->priv = (void __force *)vp_modern_map_capability(mdev,
  mdev->notify_map_cap, 
2, 2,
  off * 
mdev->notify_offset_multiplier, 2,
  NULL);
@@ -956,15 +969,15 @@ static int vp_modern_probe(struct 
virtio_pci_modern_device *mdev)
return err;
 
err = -EINVAL;
-   mdev->common = map_capability(pci_dev, common,
+   mdev->common = vp_modern_map_capability(mdev, common,
  sizeof(struct virtio_pci_common_cfg), 4,
  0, sizeof(struct virtio_pci_common_cfg),
  NULL);
if (!mdev->common)
goto err_map_common;
-   mdev->isr = map_capability(pci_dev, isr, sizeof(u8), 1,
-  0, 1,
-  NULL);
+   mdev->isr = vp_modern_map_capability(mdev, isr, sizeof(u8), 1,
+0, 1,
+NULL);
if (!mdev->isr)
goto err_map_isr;
 
@@ -989,9 +1002,10 @@ static int vp_modern_probe(struct 
virtio_pci_modern_device *mdev)
 * Otherwise, map each VQ individually later.
 */
if ((u64)notify_length + (notify_offset % PAGE_SIZE) <= PAGE_SIZE) {
-   mdev->notify_base = map_capability(pci_dev, notify, 2, 2,
-  0, notify_length,
-  >notify_len);
+   mdev->notify_base = vp_modern_map_capability(mdev, notify,
+2, 2,
+0, notify_length,
+>notify_len);
if (!mdev->notify_base)
goto err_map_notify;
} else {
@@ -1002,9 +1016,9 @@ static int vp_modern_probe(struct 
virtio_pci_modern_device *mdev)
 * is more than enough for all existing devices.
 */
if (device) {
-   mdev->device = map_capability(pci_dev, device, 0, 4,
- 0, PAGE_SIZE,
- >device_len);
+   mdev->device = vp_modern_map_capability(mdev, device, 0, 4,
+   0, PAGE_SIZE,
+   >device_len);
if (!mdev->device)
goto err_map_device;
}
-- 
2.25.1



[PATCH V3 17/19] vdpa: set the virtqueue num during register

2021-01-03 Thread Jason Wang
This patch delay the queue number setting to vDPA device
registering. This allows us to probe the virtqueue numbers between
device allocation and registering.

Reviewed-by: Stefano Garzarella 
Signed-off-by: Jason Wang 
---
 drivers/vdpa/ifcvf/ifcvf_main.c   | 5 ++---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 5 ++---
 drivers/vdpa/vdpa.c   | 8 
 drivers/vdpa/vdpa_sim/vdpa_sim.c  | 4 ++--
 include/linux/vdpa.h  | 7 +++
 5 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c
index 8b4028556cb6..d65f3221d8ed 100644
--- a/drivers/vdpa/ifcvf/ifcvf_main.c
+++ b/drivers/vdpa/ifcvf/ifcvf_main.c
@@ -438,8 +438,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
}
 
adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa,
-   dev, _vdpa_ops,
-   IFCVF_MAX_QUEUE_PAIRS * 2);
+   dev, _vdpa_ops);
if (adapter == NULL) {
IFCVF_ERR(pdev, "Failed to allocate vDPA structure");
return -ENOMEM;
@@ -463,7 +462,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
for (i = 0; i < IFCVF_MAX_QUEUE_PAIRS * 2; i++)
vf->vring[i].irq = -EINVAL;
 
-   ret = vdpa_register_device(>vdpa);
+   ret = vdpa_register_device(>vdpa, IFCVF_MAX_QUEUE_PAIRS * 2);
if (ret) {
IFCVF_ERR(pdev, "Failed to register ifcvf to vdpa bus");
goto err;
diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c 
b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index f1d54814db97..a1b9260bf04d 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -1958,8 +1958,7 @@ static int mlx5v_probe(struct auxiliary_device *adev,
max_vqs = MLX5_CAP_DEV_VDPA_EMULATION(mdev, max_num_virtio_queues);
max_vqs = min_t(u32, max_vqs, MLX5_MAX_SUPPORTED_VQS);
 
-   ndev = vdpa_alloc_device(struct mlx5_vdpa_net, mvdev.vdev, 
mdev->device, _vdpa_ops,
-2 * mlx5_vdpa_max_qps(max_vqs));
+   ndev = vdpa_alloc_device(struct mlx5_vdpa_net, mvdev.vdev, 
mdev->device, _vdpa_ops);
if (IS_ERR(ndev))
return PTR_ERR(ndev);
 
@@ -1986,7 +1985,7 @@ static int mlx5v_probe(struct auxiliary_device *adev,
if (err)
goto err_res;
 
-   err = vdpa_register_device(>vdev);
+   err = vdpa_register_device(>vdev, 2 * 
mlx5_vdpa_max_qps(max_vqs));
if (err)
goto err_reg;
 
diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index a69ffc991e13..ba89238f9898 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -61,7 +61,6 @@ static void vdpa_release_dev(struct device *d)
  * initialized but before registered.
  * @parent: the parent device
  * @config: the bus operations that is supported by this device
- * @nvqs: number of virtqueues supported by this device
  * @size: size of the parent structure that contains private data
  *
  * Driver should use vdpa_alloc_device() wrapper macro instead of
@@ -72,7 +71,6 @@ static void vdpa_release_dev(struct device *d)
  */
 struct vdpa_device *__vdpa_alloc_device(struct device *parent,
const struct vdpa_config_ops *config,
-   int nvqs,
size_t size)
 {
struct vdpa_device *vdev;
@@ -99,7 +97,6 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent,
vdev->index = err;
vdev->config = config;
vdev->features_valid = false;
-   vdev->nvqs = nvqs;
 
err = dev_set_name(>dev, "vdpa%u", vdev->index);
if (err)
@@ -122,11 +119,14 @@ EXPORT_SYMBOL_GPL(__vdpa_alloc_device);
  * vdpa_register_device - register a vDPA device
  * Callers must have a succeed call of vdpa_alloc_device() before.
  * @vdev: the vdpa device to be registered to vDPA bus
+ * @nvqs: number of virtqueues supported by this device
  *
  * Returns an error when fail to add to vDPA bus
  */
-int vdpa_register_device(struct vdpa_device *vdev)
+int vdpa_register_device(struct vdpa_device *vdev, int nvqs)
 {
+   vdev->nvqs = nvqs;
+
return device_add(>dev);
 }
 EXPORT_SYMBOL_GPL(vdpa_register_device);
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index 6a90fdb9cbfc..b129cb4dd013 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -357,7 +357,7 @@ static struct vdpasim *vdpasim_create(void)
else
ops = _net_config_ops;
 
-   vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops, 
VDPASIM_VQ_NUM);
+   vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops);
if (!vdpasim)
goto err_alloc;
 
@@ -393,7 +393,7 @@ static struct vdpasim *vdpasim_create(void)

[PATCH V3 12/19] virtio-pci-modern: introduce helper for setting/geting queue size

2021-01-03 Thread Jason Wang
This patch introduces helper for setting/getting queue size for modern
device.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_modern.c | 34 --
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index 0e62820b83ff..7a89226135af 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -262,6 +262,36 @@ static bool vp_modern_get_queue_enable(struct 
virtio_pci_modern_device *mdev,
return vp_ioread16(>common->queue_enable);
 }
 
+/*
+ * vp_modern_set_queue_size - set size for a virtqueue
+ * @mdev: the modern virtio-pci device
+ * @index: the queue index
+ * @size: the size of the virtqueue
+ */
+static void vp_modern_set_queue_size(struct virtio_pci_modern_device *mdev,
+u16 index, u16 size)
+{
+   vp_iowrite16(index, >common->queue_select);
+   vp_iowrite16(size, >common->queue_size);
+
+}
+
+/*
+ * vp_modern_get_queue_size - get size for a virtqueue
+ * @mdev: the modern virtio-pci device
+ * @index: the queue index
+ *
+ * Returns the size of the virtqueue
+ */
+static u16 vp_modern_get_queue_size(struct virtio_pci_modern_device *mdev,
+   u16 index)
+{
+   vp_iowrite16(index, >common->queue_select);
+
+   return vp_ioread16(>common->queue_size);
+
+}
+
 /* virtio config->finalize_features() implementation */
 static int vp_finalize_features(struct virtio_device *vdev)
 {
@@ -487,7 +517,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device 
*vp_dev,
vp_iowrite16(index, >queue_select);
 
/* Check if queue is either not available or already active. */
-   num = vp_ioread16(>queue_size);
+   num = vp_modern_get_queue_size(mdev, index);
if (!num || vp_modern_get_queue_enable(mdev, index))
return ERR_PTR(-ENOENT);
 
@@ -510,7 +540,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device 
*vp_dev,
return ERR_PTR(-ENOMEM);
 
/* activate the queue */
-   vp_iowrite16(virtqueue_get_vring_size(vq), >queue_size);
+   vp_modern_set_queue_size(mdev, index, virtqueue_get_vring_size(vq));
vp_modern_queue_address(mdev, index, virtqueue_get_desc_addr(vq),
virtqueue_get_avail_addr(vq),
virtqueue_get_used_addr(vq));
-- 
2.25.1



[PATCH V3 14/19] virtio-pci-modern: introduce helper to get notification offset

2021-01-03 Thread Jason Wang
This patch introduces help to get notification offset of modern device.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_modern.c | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index bccad1329871..217573f2588d 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -303,6 +303,21 @@ static u16 vp_modern_get_num_queues(struct 
virtio_pci_modern_device *mdev)
return vp_ioread16(>common->num_queues);
 }
 
+/*
+ * vp_modern_get_queue_notify_off - get notification offset for a virtqueue
+ * @mdev: the modern virtio-pci device
+ * @index: the queue index
+ *
+ * Returns the notification offset for a virtqueue
+ */
+static u16 vp_modern_get_queue_notify_off(struct virtio_pci_modern_device 
*mdev,
+ u16 index)
+{
+   vp_iowrite16(index, >common->queue_select);
+
+   return vp_ioread16(>common->queue_notify_off);
+}
+
 /* virtio config->finalize_features() implementation */
 static int vp_finalize_features(struct virtio_device *vdev)
 {
@@ -516,7 +531,6 @@ static struct virtqueue *setup_vq(struct virtio_pci_device 
*vp_dev,
 {
 
struct virtio_pci_modern_device *mdev = _dev->mdev;
-   struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
struct virtqueue *vq;
u16 num, off;
int err;
@@ -524,9 +538,6 @@ static struct virtqueue *setup_vq(struct virtio_pci_device 
*vp_dev,
if (index >= vp_modern_get_num_queues(mdev))
return ERR_PTR(-ENOENT);
 
-   /* Select the queue we're interested in */
-   vp_iowrite16(index, >queue_select);
-
/* Check if queue is either not available or already active. */
num = vp_modern_get_queue_size(mdev, index);
if (!num || vp_modern_get_queue_enable(mdev, index))
@@ -538,7 +549,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device 
*vp_dev,
}
 
/* get offset of notification word for this vq */
-   off = vp_ioread16(>queue_notify_off);
+   off = vp_modern_get_queue_notify_off(mdev, index);
 
info->msix_vector = msix_vec;
 
-- 
2.25.1



[PATCH V3 13/19] virtio-pci-modern: introduce helper for getting queue nums

2021-01-03 Thread Jason Wang
This patch introduces helper for getting queue num of modern device.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_modern.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index 7a89226135af..bccad1329871 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -292,6 +292,17 @@ static u16 vp_modern_get_queue_size(struct 
virtio_pci_modern_device *mdev,
 
 }
 
+/*
+ * vp_modern_get_num_queues - get the number of virtqueues
+ * @mdev: the modern virtio-pci device
+ *
+ * Returns the number of virtqueues
+ */
+static u16 vp_modern_get_num_queues(struct virtio_pci_modern_device *mdev)
+{
+   return vp_ioread16(>common->num_queues);
+}
+
 /* virtio config->finalize_features() implementation */
 static int vp_finalize_features(struct virtio_device *vdev)
 {
@@ -510,7 +521,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device 
*vp_dev,
u16 num, off;
int err;
 
-   if (index >= vp_ioread16(>num_queues))
+   if (index >= vp_modern_get_num_queues(mdev))
return ERR_PTR(-ENOENT);
 
/* Select the queue we're interested in */
-- 
2.25.1



[PATCH V3 11/19] virtio-pci-modern: introduce helper to set/get queue_enable

2021-01-03 Thread Jason Wang
This patch introduces a helper to set/get queue_enable for modern device.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_modern.c | 37 +-
 1 file changed, 31 insertions(+), 6 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index 05b21e18f46c..0e62820b83ff 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -234,6 +234,34 @@ static void vp_modern_queue_address(struct 
virtio_pci_modern_device *mdev,
 >queue_used_hi);
 }
 
+/*
+ * vp_modern_set_queue_enable - enable a virtqueue
+ * @mdev: the modern virtio-pci device
+ * @index: the queue index
+ * @enable: whether the virtqueue is enable or not
+ */
+static void vp_modern_set_queue_enable(struct virtio_pci_modern_device *mdev,
+  u16 index, bool enable)
+{
+   vp_iowrite16(index, >common->queue_select);
+   vp_iowrite16(enable, >common->queue_enable);
+}
+
+/*
+ * vp_modern_get_queue_enable - enable a virtqueue
+ * @mdev: the modern virtio-pci device
+ * @index: the queue index
+ *
+ * Returns whether a virtqueue is enabled or not
+ */
+static bool vp_modern_get_queue_enable(struct virtio_pci_modern_device *mdev,
+  u16 index)
+{
+   vp_iowrite16(index, >common->queue_select);
+
+   return vp_ioread16(>common->queue_enable);
+}
+
 /* virtio config->finalize_features() implementation */
 static int vp_finalize_features(struct virtio_device *vdev)
 {
@@ -460,7 +488,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device 
*vp_dev,
 
/* Check if queue is either not available or already active. */
num = vp_ioread16(>queue_size);
-   if (!num || vp_ioread16(>queue_enable))
+   if (!num || vp_modern_get_queue_enable(mdev, index))
return ERR_PTR(-ENOENT);
 
if (num & (num - 1)) {
@@ -538,7 +566,6 @@ static int vp_modern_find_vqs(struct virtio_device *vdev, 
unsigned nvqs,
  struct irq_affinity *desc)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
-   struct virtio_pci_common_cfg __iomem *cfg = vp_dev->mdev.common;
struct virtqueue *vq;
int rc = vp_find_vqs(vdev, nvqs, vqs, callbacks, names, ctx, desc);
 
@@ -548,10 +575,8 @@ static int vp_modern_find_vqs(struct virtio_device *vdev, 
unsigned nvqs,
/* Select and activate all queues. Has to be done last: once we do
 * this, there's no way to go back except reset.
 */
-   list_for_each_entry(vq, >vqs, list) {
-   vp_iowrite16(vq->index, >queue_select);
-   vp_iowrite16(1, >queue_enable);
-   }
+   list_for_each_entry(vq, >vqs, list)
+   vp_modern_set_queue_enable(_dev->mdev, vq->index, true);
 
return 0;
 }
-- 
2.25.1



[PATCH V3 10/19] virtio-pci-modern: introduce vp_modern_queue_address()

2021-01-03 Thread Jason Wang
This patch introduce a helper to set virtqueue address for modern address.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_modern.c | 33 --
 1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index 05cd409c0731..05b21e18f46c 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -210,6 +210,30 @@ static u16 vp_modern_queue_vector(struct 
virtio_pci_modern_device *mdev,
return vp_ioread16(>queue_msix_vector);
 }
 
+/*
+ * vp_modern_queue_address - set the virtqueue address
+ * @mdev: the modern virtio-pci device
+ * @index: the queue index
+ * @desc_addr: address of the descriptor area
+ * @driver_addr: address of the driver area
+ * @device_addr: address of the device area
+ */
+static void vp_modern_queue_address(struct virtio_pci_modern_device *mdev,
+   u16 index, u64 desc_addr, u64 driver_addr,
+   u64 device_addr)
+{
+   struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
+
+   vp_iowrite16(index, >queue_select);
+
+   vp_iowrite64_twopart(desc_addr, >queue_desc_lo,
+>queue_desc_hi);
+   vp_iowrite64_twopart(driver_addr, >queue_avail_lo,
+>queue_avail_hi);
+   vp_iowrite64_twopart(device_addr, >queue_used_lo,
+>queue_used_hi);
+}
+
 /* virtio config->finalize_features() implementation */
 static int vp_finalize_features(struct virtio_device *vdev)
 {
@@ -459,12 +483,9 @@ static struct virtqueue *setup_vq(struct virtio_pci_device 
*vp_dev,
 
/* activate the queue */
vp_iowrite16(virtqueue_get_vring_size(vq), >queue_size);
-   vp_iowrite64_twopart(virtqueue_get_desc_addr(vq),
->queue_desc_lo, >queue_desc_hi);
-   vp_iowrite64_twopart(virtqueue_get_avail_addr(vq),
->queue_avail_lo, >queue_avail_hi);
-   vp_iowrite64_twopart(virtqueue_get_used_addr(vq),
->queue_used_lo, >queue_used_hi);
+   vp_modern_queue_address(mdev, index, virtqueue_get_desc_addr(vq),
+   virtqueue_get_avail_addr(vq),
+   virtqueue_get_used_addr(vq));
 
if (mdev->notify_base) {
/* offset should not wrap */
-- 
2.25.1



[PATCH V3 09/19] virtio-pci-modern: introduce vp_modern_set_queue_vector()

2021-01-03 Thread Jason Wang
This patch introduces a helper to set virtqueue MSI vector.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_modern.c | 35 --
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index a128e5814045..05cd409c0731 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -191,6 +191,25 @@ static void vp_modern_set_features(struct 
virtio_pci_modern_device *mdev,
vp_iowrite32(features >> 32, >guest_feature);
 }
 
+/*
+ * vp_modern_queue_vector - set the MSIX vector for a specific virtqueue
+ * @mdev: the modern virtio-pci device
+ * @index: queue index
+ * @vector: the config vector
+ *
+ * Returns the config vector read from the device
+ */
+static u16 vp_modern_queue_vector(struct virtio_pci_modern_device *mdev,
+ u16 index, u16 vector)
+{
+   struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
+
+   vp_iowrite16(index, >queue_select);
+   vp_iowrite16(vector, >queue_msix_vector);
+   /* Flush the write out to device */
+   return vp_ioread16(>queue_msix_vector);
+}
+
 /* virtio config->finalize_features() implementation */
 static int vp_finalize_features(struct virtio_device *vdev)
 {
@@ -474,8 +493,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device 
*vp_dev,
}
 
if (msix_vec != VIRTIO_MSI_NO_VECTOR) {
-   vp_iowrite16(msix_vec, >queue_msix_vector);
-   msix_vec = vp_ioread16(>queue_msix_vector);
+   msix_vec = vp_modern_queue_vector(mdev, index, msix_vec);
if (msix_vec == VIRTIO_MSI_NO_VECTOR) {
err = -EBUSY;
goto err_assign_vector;
@@ -522,17 +540,10 @@ static void del_vq(struct virtio_pci_vq_info *info)
struct virtqueue *vq = info->vq;
struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev);
struct virtio_pci_modern_device *mdev = _dev->mdev;
-   struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
-
 
-   vp_iowrite16(vq->index, >queue_select);
-
-   if (vp_dev->msix_enabled) {
-   vp_iowrite16(VIRTIO_MSI_NO_VECTOR,
->queue_msix_vector);
-   /* Flush the write out to device */
-   vp_ioread16(>queue_msix_vector);
-   }
+   if (vp_dev->msix_enabled)
+   vp_modern_queue_vector(mdev, vq->index,
+  VIRTIO_MSI_NO_VECTOR);
 
if (!mdev->notify_base)
pci_iounmap(mdev->pci_dev, (void __force __iomem *)vq->priv);
-- 
2.25.1



[PATCH V3 08/19] virtio-pci-modern: introduce vp_modern_generation()

2021-01-03 Thread Jason Wang
This patch introduces vp_modern_generation() to get device generation.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_modern.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index cb14fc334a9c..a128e5814045 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -289,15 +289,26 @@ static void vp_set(struct virtio_device *vdev, unsigned 
offset,
}
 }
 
-static u32 vp_generation(struct virtio_device *vdev)
+/*
+ * vp_modern_generation - get the device genreation
+ * @mdev: the modern virtio-pci device
+ *
+ * Returns the genreation read from device
+ */
+static u32 vp_modern_generation(struct virtio_pci_modern_device *mdev)
 {
-   struct virtio_pci_device *vp_dev = to_vp_device(vdev);
-   struct virtio_pci_modern_device *mdev = _dev->mdev;
struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
 
return vp_ioread8(>config_generation);
 }
 
+static u32 vp_generation(struct virtio_device *vdev)
+{
+   struct virtio_pci_device *vp_dev = to_vp_device(vdev);
+
+   return vp_modern_generation(_dev->mdev);
+}
+
 /*
  * vp_modern_get_status - get the device status
  * @mdev: the modern virtio-pci device
-- 
2.25.1



[PATCH V3 02/19] virtio-pci: split out modern device

2021-01-03 Thread Jason Wang
This patch splits out the virtio-pci modern device only attributes
into another structure. While at it, a dedicated probe method for
modern only attributes is introduced. This may help for split the
logic into a dedicated module.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_common.h |  25 +++--
 drivers/virtio/virtio_pci_modern.c | 159 -
 2 files changed, 105 insertions(+), 79 deletions(-)

diff --git a/drivers/virtio/virtio_pci_common.h 
b/drivers/virtio/virtio_pci_common.h
index b2f0eb4067cb..f35ff5b6b467 100644
--- a/drivers/virtio/virtio_pci_common.h
+++ b/drivers/virtio/virtio_pci_common.h
@@ -39,22 +39,16 @@ struct virtio_pci_vq_info {
unsigned msix_vector;
 };
 
-/* Our device structure */
-struct virtio_pci_device {
-   struct virtio_device vdev;
+struct virtio_pci_modern_device {
struct pci_dev *pci_dev;
 
-   /* In legacy mode, these two point to within ->legacy. */
-   /* Where to read and clear interrupt */
-   u8 __iomem *isr;
-
-   /* Modern only fields */
-   /* The IO mapping for the PCI config space (non-legacy mode) */
struct virtio_pci_common_cfg __iomem *common;
/* Device-specific data (non-legacy mode)  */
void __iomem *device;
/* Base of vq notifications (non-legacy mode). */
void __iomem *notify_base;
+   /* Where to read and clear interrupt */
+   u8 __iomem *isr;
 
/* So we can sanity-check accesses. */
size_t notify_len;
@@ -68,6 +62,19 @@ struct virtio_pci_device {
 
int modern_bars;
 
+   struct virtio_device_id id;
+};
+
+/* Our device structure */
+struct virtio_pci_device {
+   struct virtio_device vdev;
+   struct pci_dev *pci_dev;
+   struct virtio_pci_modern_device mdev;
+
+   /* In legacy mode, these two point to within ->legacy. */
+   /* Where to read and clear interrupt */
+   u8 __iomem *isr;
+
/* Legacy only field */
/* the IO mapping for the PCI config space */
void __iomem *ioaddr;
diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index df1481fd400c..524490a94ca4 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -141,7 +141,8 @@ static void __iomem *map_capability(struct pci_dev *dev, 
int off,
 static u64 vp_get_features(struct virtio_device *vdev)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
-   struct virtio_pci_common_cfg __iomem *cfg = vp_dev->common;
+   struct virtio_pci_modern_device *mdev = _dev->mdev;
+   struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
u64 features;
 
vp_iowrite32(0, >device_feature_select);
@@ -166,7 +167,8 @@ static void vp_transport_features(struct virtio_device 
*vdev, u64 features)
 static int vp_finalize_features(struct virtio_device *vdev)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
-   struct virtio_pci_common_cfg __iomem *cfg = vp_dev->common;
+   struct virtio_pci_modern_device *mdev = _dev->mdev;
+   struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
u64 features = vdev->features;
 
/* Give virtio_ring a chance to accept features. */
@@ -194,12 +196,13 @@ static void vp_get(struct virtio_device *vdev, unsigned 
offset,
   void *buf, unsigned len)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
-   void __iomem *device = vp_dev->device;
+   struct virtio_pci_modern_device *mdev = _dev->mdev;
+   void __iomem *device = mdev->device;
u8 b;
__le16 w;
__le32 l;
 
-   BUG_ON(offset + len > vp_dev->device_len);
+   BUG_ON(offset + len > mdev->device_len);
 
switch (len) {
case 1:
@@ -231,12 +234,13 @@ static void vp_set(struct virtio_device *vdev, unsigned 
offset,
   const void *buf, unsigned len)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
-   void __iomem *device = vp_dev->device;
+   struct virtio_pci_modern_device *mdev = _dev->mdev;
+   void __iomem *device = mdev->device;
u8 b;
__le16 w;
__le32 l;
 
-   BUG_ON(offset + len > vp_dev->device_len);
+   BUG_ON(offset + len > mdev->device_len);
 
switch (len) {
case 1:
@@ -265,7 +269,8 @@ static void vp_set(struct virtio_device *vdev, unsigned 
offset,
 static u32 vp_generation(struct virtio_device *vdev)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
-   struct virtio_pci_common_cfg __iomem *cfg = vp_dev->common;
+   struct virtio_pci_modern_device *mdev = _dev->mdev;
+   struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
 
return vp_ioread8(>config_generation);
 }
@@ -274,7 +279,8 @@ static u32 vp_generation(struct virtio_device *vdev)
 static u8 vp_get_status(struct virtio_device *vdev)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
- 

[PATCH V3 03/19] virtio-pci-modern: factor out modern device initialization logic

2021-01-03 Thread Jason Wang
This patch factors out the modern device initialization logic into a
helper. Note that it still depends on the caller to enable pci device
which allows the caller to use e.g devres.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_modern.c | 50 +-
 1 file changed, 36 insertions(+), 14 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index 524490a94ca4..5d2d2ae0dfdb 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -703,11 +703,16 @@ static inline void check_offsets(void)
 offsetof(struct virtio_pci_common_cfg, queue_used_hi));
 }
 
-/* the PCI probing function */
-int virtio_pci_modern_probe(struct virtio_pci_device *vp_dev)
+/*
+ * vp_modern_probe: probe the modern virtio pci device, note that the
+ * caller is required to enable PCI device before calling this function.
+ * @mdev: the modern virtio-pci device
+ *
+ * Return 0 on succeed otherwise fail
+ */
+static int vp_modern_probe(struct virtio_pci_modern_device *mdev)
 {
-   struct virtio_pci_modern_device *mdev = _dev->mdev;
-   struct pci_dev *pci_dev = vp_dev->pci_dev;
+   struct pci_dev *pci_dev = mdev->pci_dev;
int err, common, isr, notify, device;
u32 notify_length;
u32 notify_offset;
@@ -826,18 +831,8 @@ int virtio_pci_modern_probe(struct virtio_pci_device 
*vp_dev)
  >device_len);
if (!mdev->device)
goto err_map_device;
-
-   vp_dev->vdev.config = _pci_config_ops;
-   } else {
-   vp_dev->vdev.config = _pci_config_nodev_ops;
}
 
-   vp_dev->config_vector = vp_config_vector;
-   vp_dev->setup_vq = setup_vq;
-   vp_dev->del_vq = del_vq;
-   vp_dev->isr = mdev->isr;
-   vp_dev->vdev.id = mdev->id;
-
return 0;
 
 err_map_device:
@@ -851,6 +846,33 @@ int virtio_pci_modern_probe(struct virtio_pci_device 
*vp_dev)
return err;
 }
 
+/* the PCI probing function */
+int virtio_pci_modern_probe(struct virtio_pci_device *vp_dev)
+{
+   struct virtio_pci_modern_device *mdev = _dev->mdev;
+   struct pci_dev *pci_dev = vp_dev->pci_dev;
+   int err;
+
+   mdev->pci_dev = pci_dev;
+
+   err = vp_modern_probe(mdev);
+   if (err)
+   return err;
+
+   if (mdev->device)
+   vp_dev->vdev.config = _pci_config_ops;
+   else
+   vp_dev->vdev.config = _pci_config_nodev_ops;
+
+   vp_dev->config_vector = vp_config_vector;
+   vp_dev->setup_vq = setup_vq;
+   vp_dev->del_vq = del_vq;
+   vp_dev->isr = mdev->isr;
+   vp_dev->vdev.id = mdev->id;
+
+   return 0;
+}
+
 void virtio_pci_modern_remove(struct virtio_pci_device *vp_dev)
 {
struct virtio_pci_modern_device *mdev = _dev->mdev;
-- 
2.25.1



[PATCH V3 06/19] virtio-pci-modern: introduce helpers for setting and getting status

2021-01-03 Thread Jason Wang
This patch introduces helpers to allow set and get device status.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_modern.c | 37 +++---
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index 2e37bfc89655..ccde0a41209a 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -275,41 +275,62 @@ static u32 vp_generation(struct virtio_device *vdev)
return vp_ioread8(>config_generation);
 }
 
+/*
+ * vp_modern_get_status - get the device status
+ * @mdev: the modern virtio-pci device
+ *
+ * Returns the status read from device
+ */
+static u8 vp_modern_get_status(struct virtio_pci_modern_device *mdev)
+{
+   struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
+
+   return vp_ioread8(>device_status);
+}
+
 /* config->{get,set}_status() implementations */
 static u8 vp_get_status(struct virtio_device *vdev)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
-   struct virtio_pci_modern_device *mdev = _dev->mdev;
+
+   return vp_modern_get_status(_dev->mdev);
+}
+
+/*
+ * vp_modern_set_status - set status to device
+ * @mdev: the modern virtio-pci device
+ * @status: the status set to device
+ */
+static void vp_modern_set_status(struct virtio_pci_modern_device *mdev,
+u8 status)
+{
struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
 
-   return vp_ioread8(>device_status);
+   vp_iowrite8(status, >device_status);
 }
 
 static void vp_set_status(struct virtio_device *vdev, u8 status)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
-   struct virtio_pci_modern_device *mdev = _dev->mdev;
-   struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
 
/* We should never be setting status to 0. */
BUG_ON(status == 0);
-   vp_iowrite8(status, >device_status);
+   vp_modern_set_status(_dev->mdev, status);
 }
 
 static void vp_reset(struct virtio_device *vdev)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
struct virtio_pci_modern_device *mdev = _dev->mdev;
-   struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
 
/* 0 status means a reset. */
-   vp_iowrite8(0, >device_status);
+   vp_modern_set_status(mdev, 0);
/* After writing 0 to device_status, the driver MUST wait for a read of
 * device_status to return 0 before reinitializing the device.
 * This will flush out the status write, and flush in device writes,
 * including MSI-X interrupts, if any.
 */
-   while (vp_ioread8(>device_status))
+   while (vp_modern_get_status(mdev))
msleep(1);
/* Flush pending VQ/configuration callbacks. */
vp_synchronize_vectors(vdev);
-- 
2.25.1



[PATCH V3 04/19] virtio-pci-modern: introduce vp_modern_remove()

2021-01-03 Thread Jason Wang
This patch introduces vp_modern_remove() doing device resources
cleanup to make it can be used.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_modern.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index 5d2d2ae0dfdb..4be9afad547e 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -873,9 +873,12 @@ int virtio_pci_modern_probe(struct virtio_pci_device 
*vp_dev)
return 0;
 }
 
-void virtio_pci_modern_remove(struct virtio_pci_device *vp_dev)
+/*
+ * vp_modern_probe: remove and cleanup the modern virtio pci device
+ * @mdev: the modern virtio-pci device
+ */
+static void vp_modern_remove(struct virtio_pci_modern_device *mdev)
 {
-   struct virtio_pci_modern_device *mdev = _dev->mdev;
struct pci_dev *pci_dev = mdev->pci_dev;
 
if (mdev->device)
@@ -886,3 +889,10 @@ void virtio_pci_modern_remove(struct virtio_pci_device 
*vp_dev)
pci_iounmap(pci_dev, mdev->common);
pci_release_selected_regions(pci_dev, mdev->modern_bars);
 }
+
+void virtio_pci_modern_remove(struct virtio_pci_device *vp_dev)
+{
+   struct virtio_pci_modern_device *mdev = _dev->mdev;
+
+   vp_modern_remove(mdev);
+}
-- 
2.25.1



[PATCH V3 07/19] virtio-pci-modern: introduce helpers for setting and getting features

2021-01-03 Thread Jason Wang
This patch introduces helpers for setting and getting features.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_modern.c | 43 +++---
 1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index ccde0a41209a..cb14fc334a9c 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -137,12 +137,16 @@ static void __iomem *map_capability(struct pci_dev *dev, 
int off,
return p;
 }
 
-/* virtio config->get_features() implementation */
-static u64 vp_get_features(struct virtio_device *vdev)
+/*
+ * vp_modern_get_features - get features from device
+ * @mdev: the modern virtio-pci device
+ *
+ * Returns the features read from the device
+ */
+static u64 vp_modern_get_features(struct virtio_pci_modern_device *mdev)
 {
-   struct virtio_pci_device *vp_dev = to_vp_device(vdev);
-   struct virtio_pci_modern_device *mdev = _dev->mdev;
struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
+
u64 features;
 
vp_iowrite32(0, >device_feature_select);
@@ -153,6 +157,14 @@ static u64 vp_get_features(struct virtio_device *vdev)
return features;
 }
 
+/* virtio config->get_features() implementation */
+static u64 vp_get_features(struct virtio_device *vdev)
+{
+   struct virtio_pci_device *vp_dev = to_vp_device(vdev);
+
+   return vp_modern_get_features(_dev->mdev);
+}
+
 static void vp_transport_features(struct virtio_device *vdev, u64 features)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
@@ -163,12 +175,26 @@ static void vp_transport_features(struct virtio_device 
*vdev, u64 features)
__virtio_set_bit(vdev, VIRTIO_F_SR_IOV);
 }
 
+/*
+ * vp_modern_set_features - set features to device
+ * @mdev: the modern virtio-pci device
+ * @features: the features set to device
+ */
+static void vp_modern_set_features(struct virtio_pci_modern_device *mdev,
+  u64 features)
+{
+   struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
+
+   vp_iowrite32(0, >guest_feature_select);
+   vp_iowrite32((u32)features, >guest_feature);
+   vp_iowrite32(1, >guest_feature_select);
+   vp_iowrite32(features >> 32, >guest_feature);
+}
+
 /* virtio config->finalize_features() implementation */
 static int vp_finalize_features(struct virtio_device *vdev)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
-   struct virtio_pci_modern_device *mdev = _dev->mdev;
-   struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
u64 features = vdev->features;
 
/* Give virtio_ring a chance to accept features. */
@@ -183,10 +209,7 @@ static int vp_finalize_features(struct virtio_device *vdev)
return -EINVAL;
}
 
-   vp_iowrite32(0, >guest_feature_select);
-   vp_iowrite32((u32)vdev->features, >guest_feature);
-   vp_iowrite32(1, >guest_feature_select);
-   vp_iowrite32(vdev->features >> 32, >guest_feature);
+   vp_modern_set_features(_dev->mdev, vdev->features);
 
return 0;
 }
-- 
2.25.1



[PATCH V3 05/19] virtio-pci-modern: introduce helper to set config vector

2021-01-03 Thread Jason Wang
This patch introduces vp_modern_config_vector() for setting config
vector.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_modern.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index 4be9afad547e..2e37bfc89655 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -315,9 +315,16 @@ static void vp_reset(struct virtio_device *vdev)
vp_synchronize_vectors(vdev);
 }
 
-static u16 vp_config_vector(struct virtio_pci_device *vp_dev, u16 vector)
+/*
+ * vp_modern_config_vector - set the vector for config interrupt
+ * @mdev: the modern virtio-pci device
+ * @vector: the config vector
+ *
+ * Returns the config vector read from the device
+ */
+static u16 vp_modern_config_vector(struct virtio_pci_modern_device *mdev,
+  u16 vector)
 {
-   struct virtio_pci_modern_device *mdev = _dev->mdev;
struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
 
/* Setup the vector used for configuration events */
@@ -327,6 +334,11 @@ static u16 vp_config_vector(struct virtio_pci_device 
*vp_dev, u16 vector)
return vp_ioread16(>msix_config);
 }
 
+static u16 vp_config_vector(struct virtio_pci_device *vp_dev, u16 vector)
+{
+   return vp_modern_config_vector(_dev->mdev, vector);
+}
+
 static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
  struct virtio_pci_vq_info *info,
  unsigned index,
-- 
2.25.1



[PATCH V3 01/19] virtio-pci: do not access iomem via struct virtio_pci_device directly

2021-01-03 Thread Jason Wang
Instead of accessing iomem via struct virito_pci_device directly,
tweak to call the io accessors through the iomem structure. This will
ease the splitting of modern virtio device logic.

Signed-off-by: Jason Wang 
---
 drivers/virtio/virtio_pci_modern.c | 76 ++
 1 file changed, 46 insertions(+), 30 deletions(-)

diff --git a/drivers/virtio/virtio_pci_modern.c 
b/drivers/virtio/virtio_pci_modern.c
index 3d6ae5a5e252..df1481fd400c 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -141,12 +141,13 @@ static void __iomem *map_capability(struct pci_dev *dev, 
int off,
 static u64 vp_get_features(struct virtio_device *vdev)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
+   struct virtio_pci_common_cfg __iomem *cfg = vp_dev->common;
u64 features;
 
-   vp_iowrite32(0, _dev->common->device_feature_select);
-   features = vp_ioread32(_dev->common->device_feature);
-   vp_iowrite32(1, _dev->common->device_feature_select);
-   features |= ((u64)vp_ioread32(_dev->common->device_feature) << 32);
+   vp_iowrite32(0, >device_feature_select);
+   features = vp_ioread32(>device_feature);
+   vp_iowrite32(1, >device_feature_select);
+   features |= ((u64)vp_ioread32(>device_feature) << 32);
 
return features;
 }
@@ -165,6 +166,7 @@ static void vp_transport_features(struct virtio_device 
*vdev, u64 features)
 static int vp_finalize_features(struct virtio_device *vdev)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
+   struct virtio_pci_common_cfg __iomem *cfg = vp_dev->common;
u64 features = vdev->features;
 
/* Give virtio_ring a chance to accept features. */
@@ -179,10 +181,10 @@ static int vp_finalize_features(struct virtio_device 
*vdev)
return -EINVAL;
}
 
-   vp_iowrite32(0, _dev->common->guest_feature_select);
-   vp_iowrite32((u32)vdev->features, _dev->common->guest_feature);
-   vp_iowrite32(1, _dev->common->guest_feature_select);
-   vp_iowrite32(vdev->features >> 32, _dev->common->guest_feature);
+   vp_iowrite32(0, >guest_feature_select);
+   vp_iowrite32((u32)vdev->features, >guest_feature);
+   vp_iowrite32(1, >guest_feature_select);
+   vp_iowrite32(vdev->features >> 32, >guest_feature);
 
return 0;
 }
@@ -192,6 +194,7 @@ static void vp_get(struct virtio_device *vdev, unsigned 
offset,
   void *buf, unsigned len)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
+   void __iomem *device = vp_dev->device;
u8 b;
__le16 w;
__le32 l;
@@ -200,21 +203,21 @@ static void vp_get(struct virtio_device *vdev, unsigned 
offset,
 
switch (len) {
case 1:
-   b = ioread8(vp_dev->device + offset);
+   b = ioread8(device + offset);
memcpy(buf, , sizeof b);
break;
case 2:
-   w = cpu_to_le16(ioread16(vp_dev->device + offset));
+   w = cpu_to_le16(ioread16(device + offset));
memcpy(buf, , sizeof w);
break;
case 4:
-   l = cpu_to_le32(ioread32(vp_dev->device + offset));
+   l = cpu_to_le32(ioread32(device + offset));
memcpy(buf, , sizeof l);
break;
case 8:
-   l = cpu_to_le32(ioread32(vp_dev->device + offset));
+   l = cpu_to_le32(ioread32(device + offset));
memcpy(buf, , sizeof l);
-   l = cpu_to_le32(ioread32(vp_dev->device + offset + sizeof l));
+   l = cpu_to_le32(ioread32(device + offset + sizeof l));
memcpy(buf + sizeof l, , sizeof l);
break;
default:
@@ -228,6 +231,7 @@ static void vp_set(struct virtio_device *vdev, unsigned 
offset,
   const void *buf, unsigned len)
 {
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
+   void __iomem *device = vp_dev->device;
u8 b;
__le16 w;
__le32 l;
@@ -237,21 +241,21 @@ static void vp_set(struct virtio_device *vdev, unsigned 
offset,
switch (len) {
case 1:
memcpy(, buf, sizeof b);
-   iowrite8(b, vp_dev->device + offset);
+   iowrite8(b, device + offset);
break;
case 2:
memcpy(, buf, sizeof w);
-   iowrite16(le16_to_cpu(w), vp_dev->device + offset);
+   iowrite16(le16_to_cpu(w), device + offset);
break;
case 4:
memcpy(, buf, sizeof l);
-   iowrite32(le32_to_cpu(l), vp_dev->device + offset);
+   iowrite32(le32_to_cpu(l), device + offset);
break;
case 8:
memcpy(, buf, sizeof l);
-   iowrite32(le32_to_cpu(l), vp_dev->device + offset);
+   iowrite32(le32_to_cpu(l), device + offset);
   

Re: [PATCH v5 2/2] Documentation: fpga: dfl: Add description for DFL UIO support

2021-01-03 Thread Xu Yilun
On Mon, Jan 04, 2021 at 12:24:05PM +0800, Wu, Hao wrote:
> > Subject: [PATCH v5 2/2] Documentation: fpga: dfl: Add description for DFL
> > UIO support
> >
> > This patch adds description for UIO support for dfl devices on DFL
> > bus.
> >
> > Signed-off-by: Xu Yilun 
> > ---
> > v2: no doc in v1, add it for v2.
> > v3: some documentation fixes.
> > v4: documentation change since the driver matching is changed.
> > v5: no change.
> > ---
> >  Documentation/fpga/dfl.rst | 24 
> >  1 file changed, 24 insertions(+)
> >
> > diff --git a/Documentation/fpga/dfl.rst b/Documentation/fpga/dfl.rst
> > index 0404fe6..b8497f3 100644
> > --- a/Documentation/fpga/dfl.rst
> > +++ b/Documentation/fpga/dfl.rst
> > @@ -7,6 +7,7 @@ Authors:
> >  - Enno Luebbers 
> >  - Xiao Guangrong 
> >  - Wu Hao 
> > +- Xu Yilun 
> >
> >  The Device Feature List (DFL) FPGA framework (and drivers according to
> >  this framework) hides the very details of low layer hardwares and provides
> > @@ -502,6 +503,29 @@ FME Partial Reconfiguration Sub Feature driver (see
> > drivers/fpga/dfl-fme-pr.c)
> >  could be a reference.
> >
> >
> > +UIO support for DFL devices
> > +===
> 
> I think the main purpose is to support userspace driver for DFL devices, and
> UIO is the option for now. Do you think if the title could be userspace driver
> support for DFL devices?

Yes, I could change it.

Thanks,
Yilun


[PATCH V3 00/19] vDPA driver for virtio-pci device

2021-01-03 Thread Jason Wang
Hi all:

This series tries to implement a vDPA driver for virtio-pci device
which will bridge between vDPA bus and virtio-pci device.

This could be used for future feature prototyping and testing.

Please review

Changes since V2:

- tweak config prompt
- switch from 'cb' to 'config_cb' for vp_vdpa config interrupt
- use a macro for vp_vdpa msix name length

Changes since V1:

- don't try to use devres for virtio-pci core
- tweak the commit log
- split the patches furtherly to ease the reviewing

Changes since RFC:

- Split common codes from virito-pci and share it with vDPA driver
- Use dynamic id in order to be less confusing with virtio-pci driver
- No feature whitelist, supporting any features (mq, config etc)

Thanks

Jason Wang (19):
  virtio-pci: do not access iomem via struct virtio_pci_device directly
  virtio-pci: split out modern device
  virtio-pci-modern: factor out modern device initialization logic
  virtio-pci-modern: introduce vp_modern_remove()
  virtio-pci-modern: introduce helper to set config vector
  virtio-pci-modern: introduce helpers for setting and getting status
  virtio-pci-modern: introduce helpers for setting and getting features
  virtio-pci-modern: introduce vp_modern_generation()
  virtio-pci-modern: introduce vp_modern_set_queue_vector()
  virtio-pci-modern: introduce vp_modern_queue_address()
  virtio-pci-modern: introduce helper to set/get queue_enable
  virtio-pci-modern: introduce helper for setting/geting queue size
  virtio-pci-modern: introduce helper for getting queue nums
  virtio-pci-modern: introduce helper to get notification offset
  virito-pci-modern: rename map_capability() to
vp_modern_map_capability()
  virtio-pci: introduce modern device module
  vdpa: set the virtqueue num during register
  virtio_vdpa: don't warn when fail to disable vq
  vdpa: introduce virtio pci driver

 drivers/vdpa/Kconfig   |   6 +
 drivers/vdpa/Makefile  |   1 +
 drivers/vdpa/ifcvf/ifcvf_main.c|   5 +-
 drivers/vdpa/mlx5/net/mlx5_vnet.c  |   5 +-
 drivers/vdpa/vdpa.c|   8 +-
 drivers/vdpa/vdpa_sim/vdpa_sim.c   |   4 +-
 drivers/vdpa/virtio_pci/Makefile   |   2 +
 drivers/vdpa/virtio_pci/vp_vdpa.c  | 456 +++
 drivers/virtio/Kconfig |  10 +-
 drivers/virtio/Makefile|   1 +
 drivers/virtio/virtio_pci_common.h |  22 +-
 drivers/virtio/virtio_pci_modern.c | 506 +++--
 drivers/virtio/virtio_pci_modern_dev.c | 599 +
 drivers/virtio/virtio_vdpa.c   |   3 +-
 include/linux/vdpa.h   |   7 +-
 include/linux/virtio_pci_modern.h  | 111 +
 16 files changed, 1274 insertions(+), 472 deletions(-)
 create mode 100644 drivers/vdpa/virtio_pci/Makefile
 create mode 100644 drivers/vdpa/virtio_pci/vp_vdpa.c
 create mode 100644 drivers/virtio/virtio_pci_modern_dev.c
 create mode 100644 include/linux/virtio_pci_modern.h

-- 
2.25.1



Re: [PATCH v5 1/2] fpga: dfl: add the userspace I/O device support for DFL devices

2021-01-03 Thread Xu Yilun
On Mon, Jan 04, 2021 at 12:16:30PM +0800, Wu, Hao wrote:
> > Subject: [PATCH v5 1/2] fpga: dfl: add the userspace I/O device support for
> > DFL devices
> >
> > This patch supports the DFL drivers be written in userspace. This is
> > realized by exposing the userspace I/O device interfaces.
> >
> > The driver leverages the uio_pdrv_genirq, it adds the uio_pdrv_genirq
> > platform device with the DFL device's resources, and let the generic UIO
> > platform device driver provide support to userspace access to kernel
> > interrupts and memory locations.
> >
> > The driver now supports the ether group feature. To support a new DFL
> > feature been directly accessed via UIO, its feature id should be added to
> > the driver's id_table.
> >
> > Signed-off-by: Xu Yilun 
> > Reviewed-by: Tom Rix 
> > ---
> > v2: switch to the new matching algorithem. It matches DFL devices which
> >  could not be handled by other DFL drivers.
> > refacor the code about device resources filling.
> > fix some comments.
> > v3: split the dfl.c changes out of this patch.
> > some minor fixes
> > v4: drop the idea of a generic matching algorithem, instead we specify
> >  each matching device in id_table.
> > to make clear that only one irq is supported, the irq handling code
> >  is refactored.
> > v5: refactor the irq resource code.
> > ---
> >  drivers/fpga/Kconfig| 10 +
> >  drivers/fpga/Makefile   |  1 +
> >  drivers/fpga/dfl-uio-pdev.c | 91
> > +
> >  3 files changed, 102 insertions(+)
> >  create mode 100644 drivers/fpga/dfl-uio-pdev.c
> >
> > diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig
> > index 5ff9438..61445be 100644
> > --- a/drivers/fpga/Kconfig
> > +++ b/drivers/fpga/Kconfig
> > @@ -203,6 +203,16 @@ config FPGA_DFL_NIOS_INTEL_PAC_N3000
> >the card. It also instantiates the SPI master (spi-altera) for
> >the card's BMC (Board Management Controller).
> >
> > +config FPGA_DFL_UIO_PDEV
> > +tristate "FPGA DFL Driver for Userspace I/O platform devices"
> > +depends on FPGA_DFL && UIO_PDRV_GENIRQ
> > +help
> > +  Enable this to allow some DFL drivers be written in userspace. It
> > +  adds the uio_pdrv_genirq platform device with the DFL feature's
> > +  resources, and lets the generic UIO platform device driver provide
> > +  support for userspace access to kernel interrupts and memory
> > +  locations.
> > +
> >  config FPGA_DFL_PCI
> >  tristate "FPGA DFL PCIe Device Driver"
> >  depends on PCI && FPGA_DFL
> > diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile
> > index 18dc9885..8847fe0 100644
> > --- a/drivers/fpga/Makefile
> > +++ b/drivers/fpga/Makefile
> > @@ -45,6 +45,7 @@ dfl-afu-objs := dfl-afu-main.o dfl-afu-region.o dfl-afu-
> > dma-region.o
> >  dfl-afu-objs += dfl-afu-error.o
> >
> >  obj-$(CONFIG_FPGA_DFL_NIOS_INTEL_PAC_N3000)+= dfl-n3000-nios.o
> > +obj-$(CONFIG_FPGA_DFL_UIO_PDEV)+= dfl-uio-pdev.o
> >
> >  # Drivers for FPGAs which implement DFL
> >  obj-$(CONFIG_FPGA_DFL_PCI)+= dfl-pci.o
> > diff --git a/drivers/fpga/dfl-uio-pdev.c b/drivers/fpga/dfl-uio-pdev.c
> > new file mode 100644
> > index 000..a4cd581
> > --- /dev/null
> > +++ b/drivers/fpga/dfl-uio-pdev.c
> > @@ -0,0 +1,91 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * DFL driver for Userspace I/O platform devices
> > + *
> > + * Copyright (C) 2020 Intel Corporation, Inc.
> > + */
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define DRIVER_NAME "dfl-uio-pdev"
> > +
> > +static int dfl_uio_pdev_probe(struct dfl_device *ddev)
> > +{
> > +struct platform_device_info pdevinfo = { 0 };
> > +struct uio_info uio_pdata = { 0 };
> > +struct platform_device *uio_pdev;
> > +struct device *dev = >dev;
> > +unsigned int num_res = 1;
> > +struct resource res[2];
> > +
> > +res[0].parent = >mmio_res;
> > +res[0].flags = IORESOURCE_MEM;
> > +res[0].start = ddev->mmio_res.start;
> > +res[0].end = ddev->mmio_res.end;
> > +
> > +if (ddev->num_irqs) {
> > +if (ddev->num_irqs > 1)
> > +dev_warn(>dev,
> > + "%d irqs for %s, but UIO only supports the
> > first one\n",
> > + ddev->num_irqs, dev_name(>dev));
> > +
> > +res[1].flags = IORESOURCE_IRQ;
> > +res[1].start = ddev->irqs[0];
> > +res[1].end = ddev->irqs[0];
> 
> Looks like res[] needs to be zeroed for other fields not used here.

Thanks for catching this. Will fix it.

Yilun


Re: [PATCH] staging: greybus: fix stack size warning with UBSAN

2021-01-03 Thread Dan Carpenter
On Sun, Jan 03, 2021 at 11:35:32PM +0100, Arnd Bergmann wrote:
> @@ -1050,78 +1088,28 @@ static int gbaudio_tplg_create_widget(struct 
> gbaudio_module_info *module,
>   strlcpy(temp_name, w->name, NAME_SIZE);
>   snprintf(w->name, NAME_SIZE, "GB %d %s", module->dev_id, temp_name);
>  
> + if (w->type > ARRAY_SIZE(gbaudio_widgets)) {
^^

Off by one.  >= here.


> + ret = -EINVAL;
> + goto error;
> + }
> + *dw = gbaudio_widgets[w->type];
> + dw->name = w->name;

regards,
dan carpenter



Re: [PATCH 5.10 00/40] 5.10.3-rc1 review

2021-01-03 Thread Greg Kroah-Hartman
On Sun, Jan 03, 2021 at 06:37:51PM +0530, Jeffrin Jose T wrote:
> On Mon, 2020-12-28 at 12:41 -0800, Guenter Roeck wrote:
> > On 12/28/20 1:50 AM, Pavel Machek wrote:
> > > Hi!
> > > 
> > > > > > > > > https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.3-rc1.gz
> > > > > > > > > or in the git tree and branch at:
> > > > > > > > > git://git.kernel.org/pub/scm/linux/kernel/git/s
> > > > > > > > > table/
> > > > > > > > > linu
> > > > > > > > > x-
> > > > > > > > > stable-rc.git linux-5.10.y
> > > > > > > > > and the diffstat can be found below.
> > > > > > > > > 
> > > > > > > > > thanks,
> > > > > > > > > 
> > > > > > > > > greg k-h
> > > > > > > > 
> > > > > > > > hello ,
> > > > > > > > Compiled and booted 5.10.3-rc1+.
> > > > > > > > 
> > > > > > > > dmesg -l err gives...
> > > > > > > > --x-x--->
> > > > > > > >    43.190922] Bluetooth: hci0: don't support firmware
> > > > > > > > rome
> > > > > > > > 0x31010100
> > > > > > > > --x---x->
> > > > > > > > 
> > > > > > > > My Bluetooth is Off.
> > > > > > > 
> > > > > > > Is this a new warning?  Does it show up on 5.10.2?
> > > > > > > 
> > > > > > > > Tested-by: Jeffrin Jose T 
> > > > > > > 
> > > > > > > thanks for testing?
> > > > > > > 
> > > > > > > greg k-h
> > > > > > 
> > > > > > this does not show up in 5.10.2-rc1+
> > > > > 
> > > > > Odd.  Can you run 'git bisect' to find the offending commit?
> > > > > 
> > > > > Does this same error message show up in Linus's git tree?
> > > 
> > > > i will try to do "git bisect" .  i saw this error in linus's 
> > > > tree.
> > > 
> > > The bug is in -stable, too, so it is probably easiest to do bisect
> > > on
> > > -stable tree. IIRC there's less then few hundred commits, so it
> > > should
> > > be feasible to do bisection by hand if you are not familiar with
> > > git
> > > bisect.
> > > 
> > 
> > My wild guess would be commit b260e4a68853 ("Bluetooth: Fix slab-out-
> > of-bounds
> > read in hci_le_direct_adv_report_evt()"), but I don't see what might
> > be wrong
> > with it unless some BT device sends a bad report which used to be
> > accepted
> > but is now silently ignored.
> > 
> > Guenter
> > 
> hello,
> 
> Did  "git bisect" in  a typically ok fashion and found that 5.9.0 is
> working for bluetooth related. But 5.10.0-rc1  related is not working.
> 
> some related information in bisect.txt  attached.
> 
> -- 
> software engineer
> rajagiri school of engineering and technology - autonomous
> 

> $sudo git bisect bad
> Bisecting: 0 revisions left to test after this (roughly 1 step)
> [194810f78402128fe07676646cf9027fd3ed431c] dt-bindings: leds: Update 
> devicetree documents for ID_RGB
> 
> $sudo git bisect bad
> Bisecting: 0 revisions left to test after this (roughly 0 steps)
> [3650b228f83adda7e5ee532e2b90429c03f7b9ec] Linux 5.10-rc1

That's really odd, as that commit only has a Makefile change.

Also, why run this as root?

greg k-h


ping //Re: [PATCH] proc_sysclt: fix oops caused by incorrect command parameters.

2021-01-03 Thread Xiaoming Ni

ping


On 2020/12/24 15:42, Xiaoming Ni wrote:

The process_sysctl_arg() does not check whether val is empty before
  invoking strlen(val). If the command line parameter () is incorrectly
  configured and val is empty, oops is triggered.

For example, "hung_task_panic=1" is incorrectly written as "hung_task_panic".

log:
Kernel command line:  hung_task_panic

[000n] user address but active_mm is swapper
Internal error: Oops: 9605 [#1] SMP
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.1 #1
Hardware name: linux,dummy-virt (DT)
pstate: 4005 (nZcv daif -PAN -UAO -TCO BTYPE=--)
pc : __pi_strlen+0x10/0x98
lr : process_sysctl_arg+0x1e4/0x2ac
sp : ffc01104bd40
x29: ffc01104bd40 x28: 
x27: ff80c0a4691e x26: ffc0102a7c8c
x25:  x24: ffc01104be80
x23: ff80c22f0b00 x22: ff80c02e28c0
x21: ffc0109f9000 x20: 
x19: ffc0107c08de x18: 0003
x17: ffc01105d000 x16: 0054
x15:  x14: 3030253078413830
x13:  x12: 
x11: 0101010101010101 x10: 0005
x9 : 0003 x8 : ff80c0980c08
x7 :  x6 : 0002
x5 : ff80c0235000 x4 : ff810f7c7ee0
x3 : 043a x2 : 00bdcc4ebacf1a54
x1 :  x0 : 
Call trace:
 __pi_strlen+0x10/0x98
 parse_args+0x278/0x344
 do_sysctl_args+0x8c/0xfc
 kernel_init+0x5c/0xf4
 ret_from_fork+0x10/0x30
Code: b200c3eb 927cec01 f2400c07 54000301 (a8c10c22)

Fixes: 3db978d480e2843 ("kernel/sysctl: support setting sysctl parameters
  from kernel command line")
Signed-off-by: Xiaoming Ni 
---
  fs/proc/proc_sysctl.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 317899222d7f..4516411a2b44 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -1757,6 +1757,9 @@ static int process_sysctl_arg(char *param, char *val,
loff_t pos = 0;
ssize_t wret;
  
+	if (!val)

+   return 0;
+
if (strncmp(param, "sysctl", sizeof("sysctl") - 1) == 0) {
param += sizeof("sysctl") - 1;
  





Re: [RFC 1/2] arm64/mm: Fix pfn_valid() for ZONE_DEVICE based memory

2021-01-03 Thread Anshuman Khandual


On 12/22/20 2:41 PM, David Hildenbrand wrote:
> On 22.12.20 08:12, Anshuman Khandual wrote:
>> pfn_valid() validates a pfn but basically it checks for a valid struct page
>> backing for that pfn. It should always return positive for memory ranges
>> backed with struct page mapping. But currently pfn_valid() fails for all
>> ZONE_DEVICE based memory types even though they have struct page mapping.
>>
>> pfn_valid() asserts that there is a memblock entry for a given pfn without
>> MEMBLOCK_NOMAP flag being set. The problem with ZONE_DEVICE based memory is
>> that they do not have memblock entries. Hence memblock_is_map_memory() will
>> invariably fail via memblock_search() for a ZONE_DEVICE based address. This
>> eventually fails pfn_valid() which is wrong. memblock_is_map_memory() needs
>> to be skipped for such memory ranges. As ZONE_DEVICE memory gets hotplugged
>> into the system via memremap_pages() called from a driver, their respective
>> memory sections will not have SECTION_IS_EARLY set.
>>
>> Normal hotplug memory will never have MEMBLOCK_NOMAP set in their memblock
>> regions. Because the flag MEMBLOCK_NOMAP was specifically designed and set
>> for firmware reserved memory regions. memblock_is_map_memory() can just be
>> skipped as its always going to be positive and that will be an optimization
>> for the normal hotplug memory. Like ZONE_DEVIE based memory, all hotplugged
>> normal memory too will not have SECTION_IS_EARLY set for their sections.
>>
>> Skipping memblock_is_map_memory() for all non early memory sections would
>> fix pfn_valid() problem for ZONE_DEVICE based memory and also improve its
>> performance for normal hotplug memory as well.
>>
>> Cc: Catalin Marinas 
>> Cc: Will Deacon 
>> Cc: Ard Biesheuvel 
>> Cc: Robin Murphy 
>> Cc: linux-arm-ker...@lists.infradead.org
>> Cc: linux-kernel@vger.kernel.org
>> Fixes: 73b20c84d42d ("arm64: mm: implement pte_devmap support")
>> Signed-off-by: Anshuman Khandual 
>> ---
>>  arch/arm64/mm/init.c | 12 
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
>> index 75addb36354a..ee23bda00c28 100644
>> --- a/arch/arm64/mm/init.c
>> +++ b/arch/arm64/mm/init.c
>> @@ -225,6 +225,18 @@ int pfn_valid(unsigned long pfn)
>>  
>>  if (!valid_section(__pfn_to_section(pfn)))
>>  return 0;
>> +
>> +/*
>> + * ZONE_DEVICE memory does not have the memblock entries.
>> + * memblock_is_map_memory() check for ZONE_DEVICE based
>> + * addresses will always fail. Even the normal hotplugged
>> + * memory will never have MEMBLOCK_NOMAP flag set in their
>> + * memblock entries. Skip memblock search for all non early
>> + * memory sections covering all of hotplug memory including
>> + * both normal and ZONE_DEVIE based.
>> + */
>> +if (!early_section(__pfn_to_section(pfn)))
>> +return 1;
> 
> Actually, I think we want to check for partial present sections.
> 
> Maybe we can rather switch to generic pfn_valid() and tweak it to
> something like
> 
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index fb3bf696c05e..7b1fcce5bd5a 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -1382,9 +1382,13 @@ static inline int pfn_valid(unsigned long pfn)
> return 0;
> /*
>  * Traditionally early sections always returned pfn_valid() for
> -* the entire section-sized span.
> +* the entire section-sized span. Some archs might have holes in
> +* early sections, so double check with memblock if configured.
>  */
> -   return early_section(ms) || pfn_section_valid(ms, pfn);
> +   if (early_section(ms))
> +   return IS_ENABLED(CONFIG_EARLY_SECTION_MEMMAP_HOLES) ?
> +  memblock_is_map_memory(pfn << PAGE_SHIFT) : 1;
> +   return pfn_section_valid(ms, pfn);
>  }
>  #endif

Could not find CONFIG_EARLY_SECTION_MEMMAP_HOLES. Are you suggesting to
create this config which could track platform scenarios where all early
sections might not have mmap coverage such as arm64 ?

> 
> 
> 
> Which users are remaining that require us to add/remove memblocks when
> hot(un)plugging memory
> 
>  $ git grep KEEP_MEM | grep memory_hotplug
> mm/memory_hotplug.c:if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK))
> mm/memory_hotplug.c:if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK))
> mm/memory_hotplug.c:if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) {

Did not follow, do we want to drop ARCH_KEEP_MEMBLOCK ? Without it arm64
will not be able to track MEMBLOCK_NOMAP memory at runtime.

> 
> 
> I think one user we would have to handle is
> arch/arm64/mm/mmap.c:valid_phys_addr_range(). AFAIS, powerpc at least
> does not rely on memblock_is_map_memory.

memblock_is_map_memory() is currently used only on arm/arm64 platforms.
Apart from the above example in valid_phys_addr_range(), there are some
other memblock_is_map_memory() call sites as well. But 

crypto: stm32 - Fix last sparse warning in stm32_cryp_check_ctr_counter

2021-01-03 Thread Herbert Xu
On Tue, Dec 29, 2020 at 11:26:45AM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
> master
> head:   dea8dcf2a9fa8cc540136a6cd885c3beece16ec3
> commit: bbb2832620ac4e136416aa97af7310636422dea9 crypto: stm32 - Fix sparse 
> warnings
> date:   4 months ago
> config: arm-randconfig-s032-20201220 (attached as .config)
> compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
> reproduce:
> wget 
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # apt-get install sparse
> # sparse version: v0.6.3-184-g1b896707-dirty
> # 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bbb2832620ac4e136416aa97af7310636422dea9
> git remote add linus 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout bbb2832620ac4e136416aa97af7310636422dea9
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 
> CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot 
> 
> 
> "sparse warnings: (new ones prefixed by >>)"
> >> drivers/crypto/stm32/stm32-cryp.c:1232:47: sparse: sparse: incorrect type 
> >> in argument 2 (different base types) @@ expected restricted __be32 
> >> [usertype] *[assigned] iv @@ got unsigned int [usertype] * @@
>drivers/crypto/stm32/stm32-cryp.c:1232:47: sparse: expected restricted 
> __be32 [usertype] *[assigned] iv
>drivers/crypto/stm32/stm32-cryp.c:1232:47: sparse: got unsigned int 
> [usertype] *

This patch should fix the problem.

---8<---
This patch changes the cast in stm32_cryp_check_ctr_counter from
u32 to __be32 to match the prototype of stm32_cryp_hw_write_iv
correctly.

Reported-by: kernel test robot 
Signed-off-by: Herbert Xu 

diff --git a/drivers/crypto/stm32/stm32-cryp.c 
b/drivers/crypto/stm32/stm32-cryp.c
index 2670c30332fa..2a4793176c71 100644
--- a/drivers/crypto/stm32/stm32-cryp.c
+++ b/drivers/crypto/stm32/stm32-cryp.c
@@ -1229,7 +1229,7 @@ static void stm32_cryp_check_ctr_counter(struct 
stm32_cryp *cryp)
cr = stm32_cryp_read(cryp, CRYP_CR);
stm32_cryp_write(cryp, CRYP_CR, cr & ~CR_CRYPEN);
 
-   stm32_cryp_hw_write_iv(cryp, (u32 *)cryp->last_ctr);
+   stm32_cryp_hw_write_iv(cryp, (__be32 *)cryp->last_ctr);
 
stm32_cryp_write(cryp, CRYP_CR, cr);
}
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH v3, 1/8] soc: mediatek: mmsys: create mmsys folder

2021-01-03 Thread Yongqiang Niu
On Thu, 2020-12-31 at 09:21 +0800, Nicolas Boichat wrote:
> On Mon, Dec 28, 2020 at 4:38 PM Yongqiang Niu
>  wrote:
> >
> > the mmsys will more and more complicated after support
> > more and more SoCs, add an independent folder will be
> > more clear
> >
> > Signed-off-by: Yongqiang Niu 
> > ---
> >  drivers/soc/mediatek/Makefile  |   2 +-
> >  drivers/soc/mediatek/mmsys/Makefile|   2 +
> >  drivers/soc/mediatek/mmsys/mtk-mmsys.c | 380 
> > +
> >  drivers/soc/mediatek/mtk-mmsys.c   | 380 
> > -
> 
> I wonder why this doesn't get detected as a rename?
> 

git commit --amend
[detached HEAD 1f10c05] soc: mediatek: mmsys: create mmsys folder
 3 files changed, 3 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/mediatek/mmsys/Makefile
 rename drivers/soc/mediatek/{ => mmsys}/mtk-mmsys.c (100%)


> >  4 files changed, 383 insertions(+), 381 deletions(-)
> >  create mode 100644 drivers/soc/mediatek/mmsys/Makefile
> >  create mode 100644 drivers/soc/mediatek/mmsys/mtk-mmsys.c
> >  delete mode 100644 drivers/soc/mediatek/mtk-mmsys.c
> >
> > diff --git a/drivers/soc/mediatek/Makefile b/drivers/soc/mediatek/Makefile
> > index 01f9f87..b5987ca 100644
> > --- a/drivers/soc/mediatek/Makefile
> > +++ b/drivers/soc/mediatek/Makefile
> > @@ -3,4 +3,4 @@ obj-$(CONFIG_MTK_CMDQ) += mtk-cmdq-helper.o
> >  obj-$(CONFIG_MTK_INFRACFG) += mtk-infracfg.o
> >  obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap.o
> >  obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o
> > -obj-$(CONFIG_MTK_MMSYS) += mtk-mmsys.o
> > +obj-$(CONFIG_MTK_MMSYS) += mmsys/
> > diff --git a/drivers/soc/mediatek/mmsys/Makefile 
> > b/drivers/soc/mediatek/mmsys/Makefile
> > new file mode 100644
> > index 000..5d976d7
> > --- /dev/null
> > +++ b/drivers/soc/mediatek/mmsys/Makefile
> > @@ -0,0 +1,2 @@
> > +# SPDX-License-Identifier: GPL-2.0-only
> > +obj-$(CONFIG_MTK_MMSYS) += mtk-mmsys.o
> > \ No newline at end of file
> 
> Nit: newline at end of file please.



Re: [PATCH 0/4] regulator: fix pm8009 bindings on sm8250

2021-01-03 Thread Vinod Koul
On 31-12-20, 15:23, Dmitry Baryshkov wrote:
> 
> PM8009 has special revision (P=1), which is to be used for sm8250
> platform. The major difference is the S2 regulator which supplies 0.95 V
> instead of 2.848V. Declare regulators data to be used for this chip
> revision. The datasheet calls the chip just pm8009-1, so use the same
> name.

Thanks, this looks sane to me:

Reviewed-by: Vinod Koul 

-- 
~Vinod


Re: [kbuild-all] Re: ERROR: ".crypto_skcipher_setkey" undefined!

2021-01-03 Thread Chen, Rong A




On 1/4/2021 1:21 PM, Herbert Xu wrote:

On Sun, Jan 03, 2021 at 02:37:42AM +0800, kernel test robot wrote:


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

All errors (new ones prefixed by >>):

ERROR: ".kmem_cache_alloc" [net/nfc/nfc.ko] undefined!
ERROR: ".__ubsan_handle_type_mismatch_v1" [net/nfc/nfc.ko] undefined!
ERROR: ".find_next_zero_bit" [net/nfc/nfc.ko] undefined!


...


ERROR: ".crypto_skcipher_setkey" [net/ceph/libceph.ko] undefined!


This looks like a bug in lkp.  Could you please have a look?


Hi Herbert,

Sorry for the inconvenience, the bot is not smart enough, we'll
optimize it to avoid such report.

Best Regards,
Rong Chen



Thanks,



Re: [PATCH] x86/iommu: Fix two minimal issues in check_iommu_entries()

2021-01-03 Thread Zhenzhong Duan
On Wed, Dec 30, 2020 at 3:02 PM Borislav Petkov  wrote:
>
> On Wed, Dec 23, 2020 at 02:24:12PM +0800, Zhenzhong Duan wrote:
> > check_iommu_entries() checks for cyclic dependency in iommu entries
> > and fixes the cyclic dependency by setting x->depend to NULL. But
> > this repairing isn't correct if q is in front of p, there will be
> > "EXECUTION ORDER INVALID!" report following. Fix it by NULLing
> > whichever in the front.
>
> When does "q is in front of p" happen? How does it happen?

Sorry, just realized it never happen.
>
> > The second issue is about the report of exectuion order reverse,
> > the order is reversed incorrectly in the report, fix it.
>
> I have no clue what that means.

I mean if p depends on q, then q->detect should be called before p->detect.
The message generated by printk() is wrong.

Regards
Zhenzhong


[PATCH v4 0/2] Add base layer priority id control

2021-01-03 Thread Dikshita Agarwal
This series adds base layer priority id control for encoder
and support for the same in venus driver.

Changes since v3:
- Rebased the changes on latest media tree.
- Addressed the comments.
- Added driver side implementation for new control.

Dikshita Agarwal (2):
  media: v4l2-ctrl: Add base layer priority id control.
  venus: venc : Add support for priority ID control.

 Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst | 9 +
 drivers/media/platform/qcom/venus/core.h  | 2 ++
 drivers/media/platform/qcom/venus/venc_ctrls.c| 9 -
 drivers/media/v4l2-core/v4l2-ctrls.c  | 1 +
 include/uapi/linux/v4l2-controls.h| 1 +
 5 files changed, 21 insertions(+), 1 deletion(-)

-- 
2.7.4



[PATCH v4 2/2] venus: venc : Add support for priority ID control.

2021-01-03 Thread Dikshita Agarwal
Add support for base layer priority ID control in
encoder.
This is a preparation patch to support v6.

Signed-off-by: Dikshita Agarwal 
---
 drivers/media/platform/qcom/venus/core.h   | 2 ++
 drivers/media/platform/qcom/venus/venc_ctrls.c | 9 -
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/venus/core.h 
b/drivers/media/platform/qcom/venus/core.h
index 54c42a3..a346ddc 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -274,6 +274,8 @@ struct venc_controls {
u32 hevc;
u32 vp9;
} level;
+
+   u32 base_priority_id;
 };
 
 struct venus_buffer {
diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c 
b/drivers/media/platform/qcom/venus/venc_ctrls.c
index 7d010d8..3ead51c 100644
--- a/drivers/media/platform/qcom/venus/venc_ctrls.c
+++ b/drivers/media/platform/qcom/venus/venc_ctrls.c
@@ -294,6 +294,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
return ret;
}
break;
+   case V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID:
+   ctr->base_priority_id = ctrl->val;
+   break;
default:
return -EINVAL;
}
@@ -309,7 +312,7 @@ int venc_ctrl_init(struct venus_inst *inst)
 {
int ret;
 
-   ret = v4l2_ctrl_handler_init(>ctrl_handler, 53);
+   ret = v4l2_ctrl_handler_init(>ctrl_handler, 54);
if (ret)
return ret;
 
@@ -523,6 +526,10 @@ int venc_ctrl_init(struct venus_inst *inst)
  V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX, 0,
  (MAX_LTR_FRAME_COUNT - 1), 1, 0);
 
+   v4l2_ctrl_new_std(>ctrl_handler, _ctrl_ops,
+ V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID, 0,
+ 6, 1, 0);
+
ret = inst->ctrl_handler.error;
if (ret)
goto err;
-- 
2.7.4



[PATCH v4 1/2] media: v4l2-ctrl: Add base layer priority id control.

2021-01-03 Thread Dikshita Agarwal
This control indicates the priority id to be applied
to base layer.

Signed-off-by: Dikshita Agarwal 
---
 Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst | 9 +
 drivers/media/v4l2-core/v4l2-ctrls.c  | 1 +
 include/uapi/linux/v4l2-controls.h| 1 +
 3 files changed, 11 insertions(+)

diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst 
b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
index 1675bcf..24df818 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
@@ -3655,3 +3655,12 @@ enum v4l2_mpeg_video_hevc_size_of_length_field -
This provides a bitmask which consists of bits [0, LTR_COUNT-1].
This is applicable to H264 and HEVC encoder and can be applied using
Request Api.
+
+``V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID (integer)``
+Specifies a priority identifier for the NAL unit, which will be applied to
+the base layer. By default this value is set to 0 for the base layer,
+and the next layer will have the priority ID assigned as 1, 2, 3 and so on.
+The video encoder can't decide the priority id to be applied to a layer,
+so this has to come from client.
+This is applicable to H264 and valid Range is from 0 to 63.
+Source Rec. ITU-T H.264 (06/2019); G.7.4.1.1, G.8.8.1
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 2ad6b5a..9bd795f 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -953,6 +953,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_MPEG_VIDEO_LTR_COUNT: return "LTR 
Count";
case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX:   return "frame 
LTR index";
case V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES:return "Use LTR 
Frames";
+   case V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID: return "Base 
Layer Priority ID";
case V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS:return "MPEG-2 
Slice Parameters";
case V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION:return "MPEG-2 
Quantization Matrices";
case V4L2_CID_FWHT_I_FRAME_QP:  return "FWHT 
I-Frame QP Value";
diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index c0bb87b..404e69c 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -425,6 +425,7 @@ enum v4l2_mpeg_video_multi_slice_mode {
 #define V4L2_CID_MPEG_VIDEO_LTR_COUNT  
(V4L2_CID_CODEC_BASE+230)
 #define V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX
(V4L2_CID_CODEC_BASE+231)
 #define V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES 
(V4L2_CID_CODEC_BASE+232)
+#define V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID  
(V4L2_CID_CODEC_BASE+233)
 
 /* CIDs for the MPEG-2 Part 2 (H.262) codec */
 #define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL
(V4L2_CID_CODEC_BASE+270)
-- 
2.7.4



[PATCH] ARM: ftrace: pause/unpause function graph tracer in cpu_suspend()

2021-01-03 Thread Louis Wang
From: "louis.wang1" 

Enabling function_graph tracer on ARM causes kernel panic, because the
function graph tracer updates the "return address" of a function in order
to insert a trace callback on function exit, it saves the function's
original return address in a return trace stack, but cpu_suspend() may not
return through the normal return path.

cpu_suspend() will resume directly via the cpu_resume path, but the return
trace stack has been set-up by the subfunctions of cpu_suspend(), which
makes the "return address" inconsistent with cpu_suspend().

This patch refers to Commit de818bd4522c40ea02a81b387d2fa86f989c9623
("arm64: kernel: pause/unpause function graph tracer in cpu_suspend()"),
fixes the issue by pausing/resuming the function graph tracer on the thread
executing cpu_suspend(), so that the function graph tracer state is kept
consistent across functions that enter power down states and never return
by effectively disabling graph tracer while they are executing.

Signed-off-by: louis.wang1 
---
 arch/arm/kernel/suspend.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/arch/arm/kernel/suspend.c b/arch/arm/kernel/suspend.c
index 24bd205..43f0a3e 100644
--- a/arch/arm/kernel/suspend.c
+++ b/arch/arm/kernel/suspend.c
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
+#include 
 #include 
 #include 
 #include 
@@ -26,12 +27,22 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
return -EINVAL;
 
/*
+* Function graph tracer state gets incosistent when the kernel
+* calls functions that never return (aka suspend finishers) hence
+* disable graph tracing during their execution.
+*/
+   pause_graph_tracing();
+
+   /*
 * Provide a temporary page table with an identity mapping for
 * the MMU-enable code, required for resuming.  On successful
 * resume (indicated by a zero return code), we need to switch
 * back to the correct page tables.
 */
ret = __cpu_suspend(arg, fn, __mpidr);
+
+   unpause_graph_tracing();
+
if (ret == 0) {
cpu_switch_mm(mm->pgd, mm);
local_flush_bp_all();
@@ -45,7 +56,13 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
 int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
 {
u32 __mpidr = cpu_logical_map(smp_processor_id());
-   return __cpu_suspend(arg, fn, __mpidr);
+   int ret;
+
+   pause_graph_tracing();
+   ret = __cpu_suspend(arg, fn, __mpidr);
+   unpause_graph_tracing();
+
+   return ret;
 }
 #defineidmap_pgd   NULL
 #endif
-- 
2.7.4



Re: INFO: task hung in __io_uring_task_cancel

2021-01-03 Thread Palash Oswal
Hillf -
> Can you reproduce it again against 5.11-rc1 with the tiny diff applied
> to see if there is a missing wakeup in the mainline?

Hey Hillf, thanks for sharing the diff. It seems like the reproducer
that I had sent did not work on 5.11-rc1 itself, so I'm trying to get
an updated reproducer for that.
I'm not well versed with the io_uring code yet, and therefore it'll
take me longer to get the reproducer going for 5.11-rc1.

Jens -
> Can you see if this helps? The reproducer is pretty brutal, it'll fork
> thousands of tasks with rings! But should work of course. I think this
> one is pretty straight forward, and actually an older issue with the
> poll rewaiting.

Hey Jens, I applied your diff to 5.10.4 (
b1313fe517ca3703119dcc99ef3bbf75ab42bcfb ), and unfortunately, I'm
still seeing the task being hung. Here's the console log if this helps
further -
root@syzkaller:~# [  242.840696] INFO: task repro:395 blocked for more
than 120 seconds.
[  242.846353]   Not tainted 5.10.4+ #9
[  242.849951] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs"
disables this message.
[  242.857665] task:repro   state:D stack:0 pid:  395
ppid:   394 flags:0x0004
[  242.867346] Call Trace:
[  242.870521]  __schedule+0x28d/0x7e0
[  242.873597]  ? __percpu_counter_sum+0x75/0x90
[  242.876794]  schedule+0x4f/0xc0
[  242.878803]  __io_uring_task_cancel+0xad/0xf0
[  242.880952]  ? wait_woken+0x80/0x80
[  242.882330]  bprm_execve+0x67/0x8a0
[  242.884142]  do_execveat_common+0x1d2/0x220
[  242.885610]  __x64_sys_execveat+0x5d/0x70
[  242.886708]  do_syscall_64+0x38/0x90
[  242.887727]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[  242.889298] RIP: 0033:0x7ffabedd6469
[  242.890265] RSP: 002b:7ffc56b8bc78 EFLAGS: 0246 ORIG_RAX:
0142
[  242.892055] RAX: ffda RBX:  RCX: 7ffabedd6469
[  242.893776] RDX:  RSI: 2180 RDI: 
[  242.895400] RBP: 7ffc56b8bc90 R08:  R09: 7ffc56b8bc90
[  242.896879] R10:  R11: 0246 R12: 559c19400bf0
[  242.898335] R13: 7ffc56b8bdb0 R14:  R15: 
[  363.691144] INFO: task repro:395 blocked for more than 241 seconds.
[  363.693724]   Not tainted 5.10.4+ #9
[  363.695513] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs"
disables this message.
[  363.700543] task:repro   state:D stack:0 pid:  395
ppid:   394 flags:0x0004
[  363.705747] Call Trace:
[  363.707359]  __schedule+0x28d/0x7e0
[  363.709603]  ? __percpu_counter_sum+0x75/0x90
[  363.712900]  schedule+0x4f/0xc0
[  363.715002]  __io_uring_task_cancel+0xad/0xf0
[  363.718026]  ? wait_woken+0x80/0x80
[  363.720137]  bprm_execve+0x67/0x8a0
[  363.721992]  do_execveat_common+0x1d2/0x220
[  363.723997]  __x64_sys_execveat+0x5d/0x70
[  363.725857]  do_syscall_64+0x38/0x90
[  363.727501]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[  363.729510] RIP: 0033:0x7ffabedd6469
[  363.730913] RSP: 002b:7ffc56b8bc78 EFLAGS: 0246 ORIG_RAX:
0142
[  363.733747] RAX: ffda RBX:  RCX: 7ffabedd6469
[  363.736138] RDX:  RSI: 2180 RDI: 
[  363.738431] RBP: 7ffc56b8bc90 R08:  R09: 7ffc56b8bc90
[  363.740504] R10:  R11: 0246 R12: 559c19400bf0
[  363.742560] R13: 7ffc56b8bdb0 R14:  R15: 


Re: ERROR: ".crypto_skcipher_setkey" undefined!

2021-01-03 Thread Herbert Xu
On Sun, Jan 03, 2021 at 02:37:42AM +0800, kernel test robot wrote:
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot 
> 
> All errors (new ones prefixed by >>):
> 
>ERROR: ".kmem_cache_alloc" [net/nfc/nfc.ko] undefined!
>ERROR: ".__ubsan_handle_type_mismatch_v1" [net/nfc/nfc.ko] undefined!
>ERROR: ".find_next_zero_bit" [net/nfc/nfc.ko] undefined!

...

> >> ERROR: ".crypto_skcipher_setkey" [net/ceph/libceph.ko] undefined!

This looks like a bug in lkp.  Could you please have a look?

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


RE: dmaengine : xilinx_dma two issues

2021-01-03 Thread Radhey Shyam Pandey
> -Original Message-
> From: Paul Thomas 
> Sent: Monday, December 28, 2020 10:14 AM
> To: Dan Williams ; Vinod Koul
> ; Michal Simek ; Radhey Shyam
> Pandey ; Matthew Murrian
> ; Romain Perier
> ; Krzysztof Kozlowski ; Marc
> Ferland ; Sebastian von Ohr
> ; dmaeng...@vger.kernel.org; Linux ARM  arm-ker...@lists.infradead.org>; linux-kernel  ker...@vger.kernel.org>
> Subject: dmaengine : xilinx_dma two issues
> 
> Hello,
> 
> I'm trying to get the 5.10 kernel up and running for our system, and I'm
> running into a couple of issues with xilinx_dma.
+ (Xilinx mailing list)

Thanks for bringing the issues to our notice. Replies inline.

> 
> First, commit 14ccf0aab46e 'dmaengine: xilinx_dma: In dma channel probe
> fix node order dependency' breaks our usage. Before this commit a call to:
> dma_request_chan(_dev->dev, "axi_dma_0"); returns fine, but after
> that commit it returns -19. The reason for this seems to be that the only
> channel that is setup is channel 1 (chan->id is 1 in xilinx_dma_chan_probe()).
> However in
> of_dma_xilinx_xlate() chan_id is gets set to 0 (int chan_id = dma_spec-
> >args[0];), which causes the:
> !xdev->chan[chan_id]
> test to fail in of_dma_xilinx_xlate()

What is the channel number passed in 
dmaclient DT? 

dmas = <& axi_dma_0 1>  
dma-names = "axi_dma_0"

> 
> Our device-tree entry looks like this:
> axi_dma_0: dma@80002000 {
> status = "okay";
> #dma-cells = <1>;
> compatible = "xlnx,axi-dma-1.00.a";
> interrupt-parent = <>;
> interrupts = <0 89 4>;
> reg = <0x0 0x80002000 0x0 0x1000>;
> xlnx,addrwidth = <0x20>;
> clocks = <_clk LPD_LSBUS>, <_clk LPD_LSBUS>,
> <_clk LPD_LSBUS>, <_clk LPD_LSBUS>;
> clock-names = "s_axi_lite_aclk", "m_axi_sg_aclk", "m_axi_mm2s_aclk",
> "m_axi_s2mm_aclk";
> dma-channel@80002030 {
> compatible = "xlnx,axi-dma-s2mm-channel";
> dma-channels = <0x1>;
> interrupts = <0 89 4>;
> xlnx,datawidth = <0x20>;
> xlnx,device-id = <0x0>;
> };
> };
> 
> This is on a 5.10.1 kernel on arm64 zynqmp hardware.
> 
> The second issue goes a little further back to commit e81274cd6b526
> 'dmaengine: add support to dynamic register/unregister of channels'.
> After this commit even just removing the module 'rmmod xilinx_dma',
> without ever using it, results in a kernel oops like this:
> [   37.214568] xilinx-vdma 80002000.dma: ch 0: SG disabled
> [   37.219807] xilinx-vdma 80002000.dma: WARN: Device release is not
> defined so it is not safe to unbind this driver while in use
> [   37.231299] xilinx-vdma 80002000.dma: Xilinx AXI DMA Engine Driver
> Probed!!
> [   42.100660] Unable to handle kernel paging request at virtual
> address dead0108
> [   42.108598] Mem abort info:
> [   42.111393]   ESR = 0x9644
> [   42.114443]   EC = 0x25: DABT (current EL), IL = 32 bits
> [   42.119744]   SET = 0, FnV = 0
> [   42.122794]   EA = 0, S1PTW = 0
> [   42.125918] Data abort info:
> [   42.128789]   ISV = 0, ISS = 0x0044
> [   42.132617]   CM = 0, WnR = 1
> [   42.135577] [dead0108] address between user and kernel
> address ranges
> [   42.142705] Internal error: Oops: 9644 [#1] SMP
> [   42.147566] Modules linked in: xilinx_dma(-) clk_xlnx_clock_wizard
> uio_pdrv_genirq
> [   42.155139] CPU: 1 PID: 2075 Comm: rmmod Not tainted
> 5.10.1-00026-g3a2e6dd7a05-dirty #192
> [   42.163302] Hardware name: Enclustra XU5 SOM (DT)
> [   42.167992] pstate: 4005 (nZcv daif -PAN -UAO -TCO BTYPE=--)
> [   42.173996] pc : xilinx_dma_chan_remove+0x74/0xa0 [xilinx_dma]
> [   42.179815] lr : xilinx_dma_chan_remove+0x70/0xa0 [xilinx_dma]
> [   42.185636] sp : ffc01112bca0
> [   42.188935] x29: ffc01112bca0 x28: ff80402ea640
> [   42.194238] x27:  x26: 
> [   42.199542] x25:  x24: 
> [   42.204845] x23:  x22: 
> [   42.210149] x21: ffc0088a2028 x20: ff8040c08410
> [   42.215452] x19: ff80423fa480 x18: 
> [   42.220756] x17:  x16: 
> [   42.226059] x15: ffc010ce88c8 x14: 0040
> [   42.231363] x13: ff00 x12: 
> [   42.236667] x11: 0028 x10: 7fff
> [   42.241970] x9 : 00f0dfe0 x8 : 
> [   42.247273] x7 : ffc010da4000 x6 : 
> [   42.252577] x5 : 00210d00 x4 : ffc010da4da0
> [   42.257881] x3 : ff80423fa578 x2 : 
> [   42.263184] x1 : dead0100 x0 : dead0122
> [   42.268488] Call trace:
> [   42.270923]  xilinx_dma_chan_remove+0x74/0xa0 [xilinx_dma]
> [   42.276399]  xilinx_dma_remove+0x3c/0x70 [xilinx_dma]
> [   42.281446]  platform_drv_remove+0x24/0x38
> [   42.285530]  device_release_driver_internal+0xec/0x1a8
> [   42.290659]  driver_detach+0x64/0xd8
> [   42.294226]  

[PATCH v5 1/2] media: v4l2-ctrl: add control for long term reference.

2021-01-03 Thread Dikshita Agarwal
Long Term Reference (LTR) frames are the frames that are encoded
sometime in the past and stored in the DPB buffer list to be used
as reference to encode future frames.
This change adds controls to enable this feature.

Signed-off-by: Dikshita Agarwal 
---
 .../userspace-api/media/v4l/ext-ctrls-codec.rst| 18 ++
 drivers/media/v4l2-core/v4l2-ctrls.c   | 14 ++
 include/uapi/linux/v4l2-controls.h |  3 +++
 3 files changed, 35 insertions(+)

diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst 
b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
index 400774c..1675bcf 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst
@@ -3637,3 +3637,21 @@ enum v4l2_mpeg_video_hevc_size_of_length_field -
   - Selecting this value specifies that HEVC slices are expected
 to be prefixed by Annex B start codes. According to :ref:`hevc`
 valid start codes can be 3-bytes 0x01 or 4-bytes 0x0001.
+
+``V4L2_CID_MPEG_VIDEO_LTR_COUNT (integer)``
+   Specifies the number of Long Term Reference (LTR) frames encoder needs
+   to generate or keep. This is applicable to H264 and HEVC encoder.
+
+``V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX (integer)``
+   The current frame is marked as a Long Term Reference (LTR) frame
+   and given this LTR index which ranges from 0 to LTR_COUNT-1.
+   This is applicable to H264 and HEVC encoder and can be applied using
+   Request Api.
+   Source Rec. ITU-T H.264 (06/2019); Table 7.9
+
+``V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES (bitmask)``
+   Specifies the Long Term Reference (LTR) frame(s) to be used for
+   encoding the current frame.
+   This provides a bitmask which consists of bits [0, LTR_COUNT-1].
+   This is applicable to H264 and HEVC encoder and can be applied using
+   Request Api.
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 16ab54f..2ad6b5a 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -950,6 +950,9 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE: return 
"Vertical MV Search Range";
case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: return "Repeat 
Sequence Header";
case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:   return "Force 
Key Frame";
+   case V4L2_CID_MPEG_VIDEO_LTR_COUNT: return "LTR 
Count";
+   case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX:   return "frame 
LTR index";
+   case V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES:return "Use LTR 
Frames";
case V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS:return "MPEG-2 
Slice Parameters";
case V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION:return "MPEG-2 
Quantization Matrices";
case V4L2_CID_FWHT_I_FRAME_QP:  return "FWHT 
I-Frame QP Value";
@@ -1277,6 +1280,17 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE:
*type = V4L2_CTRL_TYPE_INTEGER;
break;
+   case V4L2_CID_MPEG_VIDEO_LTR_COUNT:
+   *type = V4L2_CTRL_TYPE_INTEGER;
+   break;
+   case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX:
+   *type = V4L2_CTRL_TYPE_INTEGER;
+   *flags |= V4L2_CTRL_FLAG_EXECUTE_ON_WRITE;
+   break;
+   case V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES:
+   *type = V4L2_CTRL_TYPE_BITMASK;
+   *flags |= V4L2_CTRL_FLAG_EXECUTE_ON_WRITE;
+   break;
case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:
case V4L2_CID_PAN_RESET:
case V4L2_CID_TILT_RESET:
diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index af8dda2..c0bb87b 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -422,6 +422,9 @@ enum v4l2_mpeg_video_multi_slice_mode {
 #define V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE  
(V4L2_CID_CODEC_BASE+227)
 #define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE  
(V4L2_CID_CODEC_BASE+228)
 #define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME
(V4L2_CID_CODEC_BASE+229)
+#define V4L2_CID_MPEG_VIDEO_LTR_COUNT  
(V4L2_CID_CODEC_BASE+230)
+#define V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX
(V4L2_CID_CODEC_BASE+231)
+#define V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES 
(V4L2_CID_CODEC_BASE+232)
 
 /* CIDs for the MPEG-2 Part 2 (H.262) codec */
 #define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL
(V4L2_CID_CODEC_BASE+270)
-- 
2.7.4



[PATCH v5 2/2] venus: venc: Add support for Long Term Reference (LTR) controls

2021-01-03 Thread Dikshita Agarwal
Add support for below LTR controls in encoder:
- V4L2_CID_MPEG_VIDEO_LTR_COUNT
- V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX
- V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES

Signed-off-by: Dikshita Agarwal 
---
 drivers/media/platform/qcom/venus/venc_ctrls.c | 49 +-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c 
b/drivers/media/platform/qcom/venus/venc_ctrls.c
index 496ad4d..7d010d8 100644
--- a/drivers/media/platform/qcom/venus/venc_ctrls.c
+++ b/drivers/media/platform/qcom/venus/venc_ctrls.c
@@ -20,6 +20,7 @@
 #define INTRA_REFRESH_MBS_MAX  300
 #define AT_SLICE_BOUNDARY  \
V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY
+#define MAX_LTR_FRAME_COUNT 4
 
 static int venc_calc_bpframes(u32 gop_size, u32 conseq_b, u32 *bf, u32 *pf)
 {
@@ -72,6 +73,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
struct venc_controls *ctr = >controls.enc;
struct hfi_enable en = { .enable = 1 };
struct hfi_bitrate brate;
+   struct hfi_ltr_use ltr_use;
+   struct hfi_ltr_mark ltr_mark;
+   struct hfi_ltr_mode ltr_mode;
u32 bframes;
u32 ptype;
int ret;
@@ -259,6 +263,37 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE:
ctr->frame_skip_mode = ctrl->val;
break;
+   case V4L2_CID_MPEG_VIDEO_LTR_COUNT:
+   ptype = HFI_PROPERTY_PARAM_VENC_LTRMODE;
+   ltr_mode.ltr_count = ctrl->val;
+   ltr_mode.ltr_mode = HFI_LTR_MODE_MANUAL;
+   ltr_mode.trust_mode = 1;
+   ret = hfi_session_set_property(inst, ptype, _mode);
+   if (ret) {
+   mutex_unlock(>lock);
+   return ret;
+   }
+   break;
+   case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX:
+   ptype = HFI_PROPERTY_CONFIG_VENC_MARKLTRFRAME;
+   ltr_mark.mark_frame = ctrl->val;
+   ret = hfi_session_set_property(inst, ptype, _mark);
+   if (ret) {
+   mutex_unlock(>lock);
+   return ret;
+   }
+   break;
+   case V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES:
+   ptype = HFI_PROPERTY_CONFIG_VENC_USELTRFRAME;
+   ltr_use.ref_ltr = ctrl->val;
+   ltr_use.use_constrnt = true;
+   ltr_use.frames = 0;
+   ret = hfi_session_set_property(inst, ptype, _use);
+   if (ret) {
+   mutex_unlock(>lock);
+   return ret;
+   }
+   break;
default:
return -EINVAL;
}
@@ -274,7 +309,7 @@ int venc_ctrl_init(struct venus_inst *inst)
 {
int ret;
 
-   ret = v4l2_ctrl_handler_init(>ctrl_handler, 50);
+   ret = v4l2_ctrl_handler_init(>ctrl_handler, 53);
if (ret)
return ret;
 
@@ -476,6 +511,18 @@ int venc_ctrl_init(struct venus_inst *inst)
   (1 << 
V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT)),
   V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED);
 
+   v4l2_ctrl_new_std(>ctrl_handler, _ctrl_ops,
+ V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES, 0,
+ (MAX_LTR_FRAME_COUNT - 1), 1, 0);
+
+   v4l2_ctrl_new_std(>ctrl_handler, _ctrl_ops,
+ V4L2_CID_MPEG_VIDEO_LTR_COUNT, 0,
+ MAX_LTR_FRAME_COUNT, 1, 0);
+
+   v4l2_ctrl_new_std(>ctrl_handler, _ctrl_ops,
+ V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX, 0,
+ (MAX_LTR_FRAME_COUNT - 1), 1, 0);
+
ret = inst->ctrl_handler.error;
if (ret)
goto err;
-- 
2.7.4



[PATCH v5 0/2] Add encoder ctrls for long term reference

2021-01-03 Thread Dikshita Agarwal
This series add the encoder controls for long term reference (LTR)
and support for the same in venus driver.

changes since v4:
- Rebased the changes on latest media tree
- Addressed the comments
- Added driver side implementation for new controls.

Dikshita Agarwal (2):
  media: v4l2-ctrl: add control for long term reference.
  venus: venc: Add support for Long Term Reference (LTR) controls

 .../userspace-api/media/v4l/ext-ctrls-codec.rst| 18 
 drivers/media/platform/qcom/venus/venc_ctrls.c | 49 +-
 drivers/media/v4l2-core/v4l2-ctrls.c   | 14 +++
 include/uapi/linux/v4l2-controls.h |  3 ++
 4 files changed, 83 insertions(+), 1 deletion(-)

-- 
2.7.4



[PATCH] mm/memcontrol: fix warning in mem_cgroup_page_lruvec()

2021-01-03 Thread Hugh Dickins
Boot a CONFIG_MEMCG=y kernel with "cgroup_disabled=memory" and you are
met by a series of warnings from the VM_WARN_ON_ONCE_PAGE(!memcg, page)
recently added to the inline mem_cgroup_page_lruvec().

An earlier attempt to place that warning, in mem_cgroup_lruvec(), had
been careful to do so after weeding out the mem_cgroup_disabled() case;
but was itself invalid because of the mem_cgroup_lruvec(NULL, pgdat) in
clear_pgdat_congested() and age_active_anon().

Warning in mem_cgroup_page_lruvec() was once useful in detecting a KSM
charge bug, so may be worth keeping: but skip if mem_cgroup_disabled().

Fixes: 9a1ac2288cf1 ("mm/memcontrol:rewrite mem_cgroup_page_lruvec()")
Signed-off-by: Hugh Dickins 
---

 include/linux/memcontrol.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- 5.11-rc2/include/linux/memcontrol.h 2020-12-27 20:39:36.751923135 -0800
+++ linux/include/linux/memcontrol.h2021-01-03 19:38:24.822978559 -0800
@@ -665,7 +665,7 @@ static inline struct lruvec *mem_cgroup_
 {
struct mem_cgroup *memcg = page_memcg(page);
 
-   VM_WARN_ON_ONCE_PAGE(!memcg, page);
+   VM_WARN_ON_ONCE_PAGE(!memcg && !mem_cgroup_disabled(), page);
return mem_cgroup_lruvec(memcg, pgdat);
 }
 


Re: [PATCH 2/3] arm64: dts: qcom: sm8150: Add PSCI idle states

2021-01-03 Thread Bjorn Andersson
On Tue 29 Dec 17:19 CST 2020, Danny Lin wrote:

> On Mon, Dec 28, 2020 at10:02 AM, Bjorn Andersson wrote:
> > On Tue 22 Dec 20:00 CST 2020, Danny Lin wrote:
> > 
> > > On Sun, Dec 20, 2020 at 7:48 PM, Bjorn Andersson wrote:
> > > > On Sun 20 Dec 16:29 PST 2020, Danny Lin wrote:
> > > > 
> > > > > Like other Qualcomm SoCs, sm8150 exposes CPU and cluster idle states
> > > > > through PSCI. Define the idle states to save power when the CPU is not
> > > > > in active use.
> > > > > 
> > > > > These idle states, latency, and residency values match the downstream
> > > > > 4.14 kernel from Qualcomm as of LA.UM.8.1.r1-15600-sm8150.0.
> > > > > 
> > > > > It's worth noting that the CPU has an additional C3 power collapse 
> > > > > idle
> > > > > state between WFI and rail power collapse (with PSCI mode 0x4003),
> > > > > but it is not officially used in downstream kernels due to "thermal
> > > > > throttling issues."
> > > > > 
> > > > 
> > > > Thanks Danny for this series, very happy to see this kind of additions.
> > > > Just one small question about the cluster param below.
> > > > 
> > > > > Signed-off-by: Danny Lin 
> > > > > ---
> > > > >  arch/arm64/boot/dts/qcom/sm8150.dtsi | 50 
> > > > > 
> > > > >  1 file changed, 50 insertions(+)
> > > > > 
> > > > > diff --git a/arch/arm64/boot/dts/qcom/sm8150.dtsi 
> > > > > b/arch/arm64/boot/dts/qcom/sm8150.dtsi
> > > > > index 75ed38ee5d88..edc1fe6d7f1b 100644
> > > > > --- a/arch/arm64/boot/dts/qcom/sm8150.dtsi
> > > > > +++ b/arch/arm64/boot/dts/qcom/sm8150.dtsi
> > > > > @@ -50,6 +50,8 @@ CPU0: cpu@0 {
> > > > >   compatible = "qcom,kryo485";
> > > > >   reg = <0x0 0x0>;
> > > > >   enable-method = "psci";
> > > > > + cpu-idle-states = <_CPU_SLEEP_0
> > > > > +_SLEEP_0>;
> > > > >   next-level-cache = <_0>;
> > > > >   qcom,freq-domain = <_hw 0>;
> > > > >   #cooling-cells = <2>;
> > > > > @@ -67,6 +69,8 @@ CPU1: cpu@100 {
> > > > >   compatible = "qcom,kryo485";
> > > > >   reg = <0x0 0x100>;
> > > > >   enable-method = "psci";
> > > > > + cpu-idle-states = <_CPU_SLEEP_0
> > > > > +_SLEEP_0>;
> > > > >   next-level-cache = <_100>;
> > > > >   qcom,freq-domain = <_hw 0>;
> > > > >   #cooling-cells = <2>;
> > > > > @@ -82,6 +86,8 @@ CPU2: cpu@200 {
> > > > >   compatible = "qcom,kryo485";
> > > > >   reg = <0x0 0x200>;
> > > > >   enable-method = "psci";
> > > > > + cpu-idle-states = <_CPU_SLEEP_0
> > > > > +_SLEEP_0>;
> > > > >   next-level-cache = <_200>;
> > > > >   qcom,freq-domain = <_hw 0>;
> > > > >   #cooling-cells = <2>;
> > > > > @@ -96,6 +102,8 @@ CPU3: cpu@300 {
> > > > >   compatible = "qcom,kryo485";
> > > > >   reg = <0x0 0x300>;
> > > > >   enable-method = "psci";
> > > > > + cpu-idle-states = <_CPU_SLEEP_0
> > > > > +_SLEEP_0>;
> > > > >   next-level-cache = <_300>;
> > > > >   qcom,freq-domain = <_hw 0>;
> > > > >   #cooling-cells = <2>;
> > > > > @@ -110,6 +118,8 @@ CPU4: cpu@400 {
> > > > >   compatible = "qcom,kryo485";
> > > > >   reg = <0x0 0x400>;
> > > > >   enable-method = "psci";
> > > > > + cpu-idle-states = <_CPU_SLEEP_0
> > > > > +_SLEEP_0>;
> > > > >   next-level-cache = <_400>;
> > > > >   qcom,freq-domain = <_hw 1>;
> > > > >   #cooling-cells = <2>;
> > > > > @@ -124,6 +134,8 @@ CPU5: cpu@500 {
> > > > >   compatible = "qcom,kryo485";
> > > > >   reg = <0x0 0x500>;
> > > > >   enable-method = "psci";
> > > > > + cpu-idle-states = <_CPU_SLEEP_0
> > > > > +_SLEEP_0>;
> > > > >   next-level-cache = <_500>;
> > > > >   qcom,freq-domain = <_hw 1>;
> > > > >   #cooling-cells = <2>;
> > > > > @@ -138,6 +150,8 @@ CPU6: cpu@600 {
> > > > >   compatible = "qcom,kryo485";
> > > > >   reg = <0x0 0x600>;
> > > > >   enable-method = "psci";
> > > > > + cpu-idle-states = <_CPU_SLEEP_0
> > > > > +_SLEEP_0>;
> > > > > 

Re: [PATCH] regulator: qcom-rpmh: add QCOM_COMMAND_DB dependency

2021-01-03 Thread Bjorn Andersson
On Wed 30 Dec 08:56 CST 2020, Arnd Bergmann wrote:

> From: Arnd Bergmann 
> 
> A built-in regulator driver cannot link against a modular cmd_db driver:
> 
> qcom-rpmh-regulator.c:(.text+0x174): undefined reference to `cmd_db_read_addr'
> 
> There is already a dependency for RPMh, so add another one of this
> type for cmd_db.
> 
> Fixes: 34c5aa2666db ("regulator: Kconfig: Fix REGULATOR_QCOM_RPMH 
> dependencies to avoid build error")
> Fixes: 46fc033eba42 ("regulator: add QCOM RPMh regulator driver")
> Signed-off-by: Arnd Bergmann 

Reviewed-by: Bjorn Andersson 

Regards,
Bjorn

> ---
>  drivers/regulator/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
> index 53fa84f4d1e1..5abdd29fb9f3 100644
> --- a/drivers/regulator/Kconfig
> +++ b/drivers/regulator/Kconfig
> @@ -881,6 +881,7 @@ config REGULATOR_QCOM_RPM
>  config REGULATOR_QCOM_RPMH
>   tristate "Qualcomm Technologies, Inc. RPMh regulator driver"
>   depends on QCOM_RPMH || (QCOM_RPMH=n && COMPILE_TEST)
> + depends on QCOM_COMMAND_DB || (QCOM_COMMAND_DB=n && COMPILE_TEST)
>   help
> This driver supports control of PMIC regulators via the RPMh hardware
> block found on Qualcomm Technologies Inc. SoCs.  RPMh regulator
> -- 
> 2.29.2
> 


RE: [PATCH v5 2/2] Documentation: fpga: dfl: Add description for DFL UIO support

2021-01-03 Thread Wu, Hao
> Subject: [PATCH v5 2/2] Documentation: fpga: dfl: Add description for DFL
> UIO support
> 
> This patch adds description for UIO support for dfl devices on DFL
> bus.
> 
> Signed-off-by: Xu Yilun 
> ---
> v2: no doc in v1, add it for v2.
> v3: some documentation fixes.
> v4: documentation change since the driver matching is changed.
> v5: no change.
> ---
>  Documentation/fpga/dfl.rst | 24 
>  1 file changed, 24 insertions(+)
> 
> diff --git a/Documentation/fpga/dfl.rst b/Documentation/fpga/dfl.rst
> index 0404fe6..b8497f3 100644
> --- a/Documentation/fpga/dfl.rst
> +++ b/Documentation/fpga/dfl.rst
> @@ -7,6 +7,7 @@ Authors:
>  - Enno Luebbers 
>  - Xiao Guangrong 
>  - Wu Hao 
> +- Xu Yilun 
> 
>  The Device Feature List (DFL) FPGA framework (and drivers according to
>  this framework) hides the very details of low layer hardwares and provides
> @@ -502,6 +503,29 @@ FME Partial Reconfiguration Sub Feature driver (see
> drivers/fpga/dfl-fme-pr.c)
>  could be a reference.
> 
> 
> +UIO support for DFL devices
> +===

I think the main purpose is to support userspace driver for DFL devices, and
UIO is the option for now. Do you think if the title could be userspace driver
support for DFL devices? 

Hao

> +The purpose of an FPGA is to be reprogrammed with newly developed
> hardware
> +components. New hardware can instantiate a new private feature in the
> DFL, and
> +then get a DFL device in their system. In some cases users may need a
> userspace
> +driver for the DFL device:
> +
> +* Users may need to run some diagnostic test for their hardwares.
> +* Users may prototype the kernel driver in user space.
> +* Some hardware is designed for specific purposes and does not fit into one
> of
> +  the standard kernel subsystems.
> +
> +This requires the direct access to the MMIO space and interrupt handling in
> +userspace. The dfl-uio-pdev module exposes the UIO device interfaces for
> this
> +purpose. It adds the uio_pdrv_genirq platform device with the resources of
> +the DFL feature, and lets the generic UIO platform device driver provide UIO
> +support to userspace.
> +
> +FPGA_DFL_UIO_PDEV should be selected to enable the dfl-uio-pdev module
> driver.
> +To support a new DFL feature been directly accessed via UIO, its feature id
> +should be added to the driver's id_table.
> +
> +
>  Open discussion
>  ===
>  FME driver exports one ioctl (DFL_FPGA_FME_PORT_PR) for partial
> reconfiguration
> --
> 2.7.4



RE: [PATCH v5 1/2] fpga: dfl: add the userspace I/O device support for DFL devices

2021-01-03 Thread Wu, Hao
> Subject: [PATCH v5 1/2] fpga: dfl: add the userspace I/O device support for
> DFL devices
> 
> This patch supports the DFL drivers be written in userspace. This is
> realized by exposing the userspace I/O device interfaces.
> 
> The driver leverages the uio_pdrv_genirq, it adds the uio_pdrv_genirq
> platform device with the DFL device's resources, and let the generic UIO
> platform device driver provide support to userspace access to kernel
> interrupts and memory locations.
> 
> The driver now supports the ether group feature. To support a new DFL
> feature been directly accessed via UIO, its feature id should be added to
> the driver's id_table.
> 
> Signed-off-by: Xu Yilun 
> Reviewed-by: Tom Rix 
> ---
> v2: switch to the new matching algorithem. It matches DFL devices which
>  could not be handled by other DFL drivers.
> refacor the code about device resources filling.
> fix some comments.
> v3: split the dfl.c changes out of this patch.
> some minor fixes
> v4: drop the idea of a generic matching algorithem, instead we specify
>  each matching device in id_table.
> to make clear that only one irq is supported, the irq handling code
>  is refactored.
> v5: refactor the irq resource code.
> ---
>  drivers/fpga/Kconfig| 10 +
>  drivers/fpga/Makefile   |  1 +
>  drivers/fpga/dfl-uio-pdev.c | 91
> +
>  3 files changed, 102 insertions(+)
>  create mode 100644 drivers/fpga/dfl-uio-pdev.c
> 
> diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig
> index 5ff9438..61445be 100644
> --- a/drivers/fpga/Kconfig
> +++ b/drivers/fpga/Kconfig
> @@ -203,6 +203,16 @@ config FPGA_DFL_NIOS_INTEL_PAC_N3000
> the card. It also instantiates the SPI master (spi-altera) for
> the card's BMC (Board Management Controller).
> 
> +config FPGA_DFL_UIO_PDEV
> + tristate "FPGA DFL Driver for Userspace I/O platform devices"
> + depends on FPGA_DFL && UIO_PDRV_GENIRQ
> + help
> +   Enable this to allow some DFL drivers be written in userspace. It
> +   adds the uio_pdrv_genirq platform device with the DFL feature's
> +   resources, and lets the generic UIO platform device driver provide
> +   support for userspace access to kernel interrupts and memory
> +   locations.
> +
>  config FPGA_DFL_PCI
>   tristate "FPGA DFL PCIe Device Driver"
>   depends on PCI && FPGA_DFL
> diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile
> index 18dc9885..8847fe0 100644
> --- a/drivers/fpga/Makefile
> +++ b/drivers/fpga/Makefile
> @@ -45,6 +45,7 @@ dfl-afu-objs := dfl-afu-main.o dfl-afu-region.o dfl-afu-
> dma-region.o
>  dfl-afu-objs += dfl-afu-error.o
> 
>  obj-$(CONFIG_FPGA_DFL_NIOS_INTEL_PAC_N3000)  += dfl-n3000-nios.o
> +obj-$(CONFIG_FPGA_DFL_UIO_PDEV)  += dfl-uio-pdev.o
> 
>  # Drivers for FPGAs which implement DFL
>  obj-$(CONFIG_FPGA_DFL_PCI)   += dfl-pci.o
> diff --git a/drivers/fpga/dfl-uio-pdev.c b/drivers/fpga/dfl-uio-pdev.c
> new file mode 100644
> index 000..a4cd581
> --- /dev/null
> +++ b/drivers/fpga/dfl-uio-pdev.c
> @@ -0,0 +1,91 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * DFL driver for Userspace I/O platform devices
> + *
> + * Copyright (C) 2020 Intel Corporation, Inc.
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define DRIVER_NAME "dfl-uio-pdev"
> +
> +static int dfl_uio_pdev_probe(struct dfl_device *ddev)
> +{
> + struct platform_device_info pdevinfo = { 0 };
> + struct uio_info uio_pdata = { 0 };
> + struct platform_device *uio_pdev;
> + struct device *dev = >dev;
> + unsigned int num_res = 1;
> + struct resource res[2];
> +
> + res[0].parent = >mmio_res;
> + res[0].flags = IORESOURCE_MEM;
> + res[0].start = ddev->mmio_res.start;
> + res[0].end = ddev->mmio_res.end;
> +
> + if (ddev->num_irqs) {
> + if (ddev->num_irqs > 1)
> + dev_warn(>dev,
> +  "%d irqs for %s, but UIO only supports the
> first one\n",
> +  ddev->num_irqs, dev_name(>dev));
> +
> + res[1].flags = IORESOURCE_IRQ;
> + res[1].start = ddev->irqs[0];
> + res[1].end = ddev->irqs[0];

Looks like res[] needs to be zeroed for other fields not used here.
other places look good to me.

Hao

> + num_res++;
> + }
> +
> + uio_pdata.name = DRIVER_NAME;
> + uio_pdata.version = "0";
> +
> + pdevinfo.name = "uio_pdrv_genirq";
> + pdevinfo.res = res;
> + pdevinfo.num_res = num_res;
> + pdevinfo.parent = >dev;
> + pdevinfo.id = PLATFORM_DEVID_AUTO;
> + pdevinfo.data = _pdata;
> + pdevinfo.size_data = sizeof(uio_pdata);
> +
> + uio_pdev = platform_device_register_full();
> + if (!IS_ERR(uio_pdev))
> + dev_set_drvdata(dev, uio_pdev);
> +
> + return PTR_ERR_OR_ZERO(uio_pdev);
> +}
> +
> +static 

Re: [PATCH 00/10] Cover letter: fix a race in release_task when flushing the dentry

2021-01-03 Thread Wen Yang




在 2020/12/31 下午5:22, Greg Kroah-Hartman 写道:

On Thu, Dec 17, 2020 at 10:26:23AM +0800, Wen Yang wrote:



在 2020/12/4 上午2:31, Wen Yang 写道:

The dentries such as /proc//ns/ have the DCACHE_OP_DELETE flag, they
should be deleted when the process exits.

Suppose the following race appears:

release_task     dput
-> proc_flush_task
       -> dentry->d_op->d_delete(dentry)
-> __exit_signal
   -> dentry->d_lockref.count--  and return.

In the proc_flush_task(), if another process is using this dentry, it will
not be deleted. At the same time, in dput(), d_op->d_delete() can be executed
before __exit_signal(pid has not been hashed), d_delete returns false, so
this dentry still cannot be deleted.

This dentry will always be cached (although its count is 0 and the
DCACHE_OP_DELETE flag is set), its parent denry will also be cached too, and
these dentries can only be deleted when drop_caches is manually triggered.

This will result in wasted memory. What's more troublesome is that these
dentries reference pid, according to the commit f333c700c610 ("pidns: Add a
limit on the number of pid namespaces"), if the pid cannot be released, it
may result in the inability to create a new pid_ns.

This problem occurred in our cluster environment (Linux 4.9 LTS).
We could reproduce it by manually constructing a test program + adding some
debugging switches in the kernel:
* A test program to open the directory (/proc//ns) [1]
* Adding some debugging switches to the kernel, adding a delay between
 proc_flush_task and __exit_signal in release_task() [2]

The test process is as follows:

A, terminal #1

Turn on the debug switch:
echo 1> /proc/sys/vm/dentry_debug_trace

Execute the following unshare command:
sudo unshare --pid --fork --mount-proc bash


B, terminal #2

Find the pid of the unshare process:

# pstree -p | grep unshare
 | `-sshd(716)---bash(718)--sudo(816)---unshare(817)---bash(818)


Find the corresponding dentry:
# dmesg | grep pid=818
[70.424722] XXX proc_pid_instantiate:3119 pid=818 tid=818 
entry=818/8802c7b670e8


C, terminal #3

Execute the opendir program, it will always open the /proc/818/ns/ directory:

# ./a.out /proc/818/ns/
pid: 876
.
..
net
uts
ipc
pid
user
mnt
cgroup

D, go back to terminal #2

Turn on the debugging switches to construct the race:
# echo 818> /proc/sys/vm/dentry_debug_pid
# echo 1> /proc/sys/vm/dentry_debug_delay

Kill the unshare process (pid 818). Since the debugging switches have been
turned on, it will get stuck in release_task():
# kill -9 818

Then kill the process that opened the /proc/818/ns/ directory:
# kill -9 876

Then turn off these debugging switches to allow the 818 process to exit:
# echo 0> /proc/sys/vm/dentry_debug_delay
# echo 0> /proc/sys/vm/dentry_debug_pid

Checking the dmesg, we will find that the dentry(/proc/818/ns) ’s count is 0,
and the flag is 2800cc (#define DCACHE_OP_DELETE 0x0008), but it is still
cached:
# dmesg | grep 8802a3999548
…
[565.559156] XXX dput:853 dentry=ns/8802bea7b528, flag=2800cc, cnt=0, 
inode=8802b38c2010, pdentry=818/8802c7b670e8, pflag=20008c, pcnt=1, 
pinode=8802c7812010, keywords: be cached


It could also be verified via the crash tool:

crash> dentry.d_flags,d_iname,d_inode,d_lockref -x  8802bea7b528
d_flags = 0x2800cc
d_iname = "ns\000"
d_inode = 0x8802b38c2010
d_lockref = {
  {
lock_count = 0x0,
{
  lock = {
{
  rlock = {
raw_lock = {
  {
val = {
  counter = 0x0
},
{
  locked = 0x0,
  pending = 0x0
},
{
  locked_pending = 0x0,
  tail = 0x0
}
  }
}
  }
}
  },
  count = 0x0
}
  }
}
crash> kmem  8802bea7b528
CACHE OBJSIZE  ALLOCATED TOTAL  SLABS  SSIZE  NAME
8802dd5f5900  192  23663 2613087116k  dentry
SLAB  MEMORYNODE  TOTAL  ALLOCATED  FREE
ea000afa9e00  8802bea78000 0 30 25 5
FREE / [ALLOCATED]
[8802bea7b520]

PAGEPHYSICAL  MAPPING   INDEX CNT FLAGS
ea000afa9ec0 2bea7b000 dead04000  0 2f8000
crash>

This series of patches is to fix this issue.

Regards,
Wen

Alexey Dobriyan (1):
proc: use %u for pid printing and slightly less stack

Andreas Gruenbacher (1):
proc: Pass file mode to proc_pid_make_inode

Christian Brauner (1):
clone: add CLONE_PIDFD

Eric W. Biederman (6):
proc: Better ownership of files for non-dumpable tasks in user
  namespaces
proc: Rename in proc_inode rename sysctl_inodes 

[PATCH v4 3/4] mtd: rawnand: qcom: Add support for Qcom SMEM parser

2021-01-03 Thread Manivannan Sadhasivam
Add support for using Qualcomm SMEM based flash partition parser in
Qualcomm NAND controller.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/mtd/nand/raw/qcom_nandc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/qcom_nandc.c 
b/drivers/mtd/nand/raw/qcom_nandc.c
index 667e4bfe369f..fd4c318b520f 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -2821,6 +2821,8 @@ static int qcom_nandc_setup(struct qcom_nand_controller 
*nandc)
return 0;
 }
 
+static const char * const probes[] = { "qcomsmem", NULL };
+
 static int qcom_nand_host_init_and_register(struct qcom_nand_controller *nandc,
struct qcom_nand_host *host,
struct device_node *dn)
@@ -2884,7 +2886,7 @@ static int qcom_nand_host_init_and_register(struct 
qcom_nand_controller *nandc,
}
}
 
-   ret = mtd_device_register(mtd, NULL, 0);
+   ret = mtd_device_parse_register(mtd, probes, NULL, NULL, 0);
if (ret)
nand_cleanup(chip);
 
-- 
2.25.1



[PATCH v4 2/4] mtd: parsers: Add Qcom SMEM parser

2021-01-03 Thread Manivannan Sadhasivam
NAND based Qualcomm platforms have the partition table populated in the
Shared Memory (SMEM). Hence, add a parser for parsing the partitions
from it.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/mtd/parsers/Kconfig|   8 ++
 drivers/mtd/parsers/Makefile   |   1 +
 drivers/mtd/parsers/qcomsmempart.c | 170 +
 3 files changed, 179 insertions(+)
 create mode 100644 drivers/mtd/parsers/qcomsmempart.c

diff --git a/drivers/mtd/parsers/Kconfig b/drivers/mtd/parsers/Kconfig
index e72354322f62..d90c30229052 100644
--- a/drivers/mtd/parsers/Kconfig
+++ b/drivers/mtd/parsers/Kconfig
@@ -160,3 +160,11 @@ config MTD_REDBOOT_PARTS_READONLY
  'FIS directory' images, enable this option.
 
 endif # MTD_REDBOOT_PARTS
+
+config MTD_QCOMSMEM_PARTS
+   tristate "Qualcomm SMEM NAND flash partition parser"
+   depends on MTD_NAND_QCOM || COMPILE_TEST
+   depends on QCOM_SMEM
+   help
+ This provides support for parsing partitions from Shared Memory (SMEM)
+ for NAND flash on Qualcomm platforms.
diff --git a/drivers/mtd/parsers/Makefile b/drivers/mtd/parsers/Makefile
index b0c5f62f9e85..50eb0b0a2210 100644
--- a/drivers/mtd/parsers/Makefile
+++ b/drivers/mtd/parsers/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o
 obj-$(CONFIG_MTD_PARSER_TRX)   += parser_trx.o
 obj-$(CONFIG_MTD_SHARPSL_PARTS)+= sharpslpart.o
 obj-$(CONFIG_MTD_REDBOOT_PARTS)+= redboot.o
+obj-$(CONFIG_MTD_QCOMSMEM_PARTS)   += qcomsmempart.o
diff --git a/drivers/mtd/parsers/qcomsmempart.c 
b/drivers/mtd/parsers/qcomsmempart.c
new file mode 100644
index ..808cb33d71f8
--- /dev/null
+++ b/drivers/mtd/parsers/qcomsmempart.c
@@ -0,0 +1,170 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Qualcomm SMEM NAND flash partition parser
+ *
+ * Copyright (C) 2020, Linaro Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SMEM_AARM_PARTITION_TABLE  9
+#define SMEM_APPS  0
+
+#define SMEM_FLASH_PART_MAGIC1 0x55ee73aa
+#define SMEM_FLASH_PART_MAGIC2 0xe35ebddb
+#define SMEM_FLASH_PTABLE_V3   3
+#define SMEM_FLASH_PTABLE_V4   4
+#define SMEM_FLASH_PTABLE_MAX_PARTS_V3 16
+#define SMEM_FLASH_PTABLE_MAX_PARTS_V4 48
+#define SMEM_FLASH_PTABLE_HDR_LEN  (4 * sizeof(u32))
+#define SMEM_FLASH_PTABLE_NAME_SIZE16
+
+/**
+ * struct smem_flash_pentry - SMEM Flash partition entry
+ * @name: Name of the partition
+ * @offset: Offset in blocks
+ * @length: Length of the partition in blocks
+ * @attr: Flags for this partition
+ */
+struct smem_flash_pentry {
+   char name[SMEM_FLASH_PTABLE_NAME_SIZE];
+   __le32 offset;
+   __le32 length;
+   u8 attr;
+} __packed __aligned(4);
+
+/**
+ * struct smem_flash_ptable - SMEM Flash partition table
+ * @magic1: Partition table Magic 1
+ * @magic2: Partition table Magic 2
+ * @version: Partition table version
+ * @numparts: Number of partitions in this ptable
+ * @pentry: Flash partition entries belonging to this ptable
+ */
+struct smem_flash_ptable {
+   __le32 magic1;
+   __le32 magic2;
+   __le32 version;
+   __le32 numparts;
+   struct smem_flash_pentry pentry[SMEM_FLASH_PTABLE_MAX_PARTS_V4];
+} __packed __aligned(4);
+
+static int parse_qcomsmem_part(struct mtd_info *mtd,
+  const struct mtd_partition **pparts,
+  struct mtd_part_parser_data *data)
+{
+   struct smem_flash_pentry *pentry;
+   struct smem_flash_ptable *ptable;
+   size_t len = SMEM_FLASH_PTABLE_HDR_LEN;
+   struct mtd_partition *parts;
+   int ret, i, numparts;
+   char *name, *c;
+
+   pr_debug("Parsing partition table info from SMEM\n");
+   ptable = qcom_smem_get(SMEM_APPS, SMEM_AARM_PARTITION_TABLE, );
+   if (IS_ERR(ptable)) {
+   pr_err("Error reading partition table header\n");
+   return PTR_ERR(ptable);
+   }
+
+   /* Verify ptable magic */
+   if (le32_to_cpu(ptable->magic1) != SMEM_FLASH_PART_MAGIC1 ||
+   le32_to_cpu(ptable->magic2) != SMEM_FLASH_PART_MAGIC2) {
+   pr_err("Partition table magic verification failed\n");
+   return -EINVAL;
+   }
+
+   /* Ensure that # of partitions is less than the max we have allocated */
+   numparts = le32_to_cpu(ptable->numparts);
+   if (numparts > SMEM_FLASH_PTABLE_MAX_PARTS_V4) {
+   pr_err("Partition numbers exceed the max limit\n");
+   return -EINVAL;
+   }
+
+   /* Find out length of partition data based on table version */
+   if (le32_to_cpu(ptable->version) <= SMEM_FLASH_PTABLE_V3) {
+   len = SMEM_FLASH_PTABLE_HDR_LEN + 
SMEM_FLASH_PTABLE_MAX_PARTS_V3 *
+   sizeof(struct smem_flash_pentry);
+   } else if (le32_to_cpu(ptable->version) == SMEM_FLASH_PTABLE_V4) {
+   

[PATCH v4 4/4] mtd: parsers: afs: Fix freeing the part name memory in failure

2021-01-03 Thread Manivannan Sadhasivam
In the case of failure while parsing the partitions, the iterator should
be pre decremented by one before starting to free the memory allocated
by kstrdup(). Because in the failure case, kstrdup() will not succeed
and thus no memory will be allocated for the current iteration.

Fixes: 1fca1f6abb38 ("mtd: afs: simplify partition parsing")
Signed-off-by: Manivannan Sadhasivam 
Reviewed-by: Linus Walleij 
Cc: Linus Walleij 
---
 drivers/mtd/parsers/afs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mtd/parsers/afs.c b/drivers/mtd/parsers/afs.c
index 980e332bdac4..26116694c821 100644
--- a/drivers/mtd/parsers/afs.c
+++ b/drivers/mtd/parsers/afs.c
@@ -370,10 +370,8 @@ static int parse_afs_partitions(struct mtd_info *mtd,
return i;
 
 out_free_parts:
-   while (i >= 0) {
+   while (--i >= 0)
kfree(parts[i].name);
-   i--;
-   }
kfree(parts);
*pparts = NULL;
return ret;
-- 
2.25.1



[PATCH v4 1/4] dt-bindings: mtd: partitions: Add binding for Qcom SMEM parser

2021-01-03 Thread Manivannan Sadhasivam
Add YAML binding for Qualcomm Shared Memory (SMEM) Flash partition
parser.

Signed-off-by: Manivannan Sadhasivam 
Reviewed-by: Rob Herring 
---
 .../mtd/partitions/qcom,smem-part.yaml| 33 +++
 1 file changed, 33 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml

diff --git 
a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml 
b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
new file mode 100644
index ..cf3f8c1e035d
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mtd/partitions/qcom,smem-part.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm SMEM NAND flash partition parser binding
+
+maintainers:
+  - Manivannan Sadhasivam 
+
+description: |
+  The Qualcomm SoCs supporting the NAND controller interface features a Shared
+  Memory (SMEM) based partition table scheme. The maximum partitions supported
+  varies between partition table revisions. V3 supports maximum 16 partitions
+  and V4 supports 48 partitions.
+
+properties:
+  compatible:
+const: qcom,smem-part
+
+required:
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+flash {
+partitions {
+compatible = "qcom,smem-part";
+};
+};
-- 
2.25.1



[PATCH v4 0/4] Add support for Qcom SMEM based NAND parser

2021-01-03 Thread Manivannan Sadhasivam
Hello,

This series adds support for parsing the partitions defined in Shared
Memory (SMEM) of the Qualcomm platforms supporting NAND interface.
Current parser only supports V3 and V4 of the partition tables.

This series has been tested on SDX55 MTP board which has an onboard NAND
device.

Thanks,
Mani

Changes in v4:

* Added Rob's review for binding

Changes in v3:

* Handled le32 parameters in parser, collected review from Linus W.

Changes in v2:

* Added additionalProperties: false and removed unit address in binding

Manivannan Sadhasivam (4):
  dt-bindings: mtd: partitions: Add binding for Qcom SMEM parser
  mtd: parsers: Add Qcom SMEM parser
  mtd: rawnand: qcom: Add support for Qcom SMEM parser
  mtd: parsers: afs: Fix freeing the part name memory in failure

 .../mtd/partitions/qcom,smem-part.yaml|  33 
 drivers/mtd/nand/raw/qcom_nandc.c |   4 +-
 drivers/mtd/parsers/Kconfig   |   8 +
 drivers/mtd/parsers/Makefile  |   1 +
 drivers/mtd/parsers/afs.c |   4 +-
 drivers/mtd/parsers/qcomsmempart.c| 170 ++
 6 files changed, 216 insertions(+), 4 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
 create mode 100644 drivers/mtd/parsers/qcomsmempart.c

-- 
2.25.1



RE: [PATCH v8 13/16] dmaengine: dw-axi-dmac: Add Intel KeemBay AxiDMA handshake

2021-01-03 Thread Sia, Jee Heng



> -Original Message-
> From: Eugeniy Paltsev 
> Sent: 31 December 2020 8:44 PM
> To: Sia, Jee Heng ; Vinod Koul
> 
> Cc: andriy.shevche...@linux.intel.com; dmaeng...@vger.kernel.org;
> linux-kernel@vger.kernel.org; devicet...@vger.kernel.org;
> robh...@kernel.org
> Subject: Re: [PATCH v8 13/16] dmaengine: dw-axi-dmac: Add Intel
> KeemBay AxiDMA handshake
> 
> Hi Sia Jee Heng,
> 
> see my comments inlined:
> 
> > From: Sia Jee Heng 
> > Sent: Tuesday, December 29, 2020 07:47
> > To: vk...@kernel.org; Eugeniy Paltsev; robh...@kernel.org
> > Cc: andriy.shevche...@linux.intel.com;
> dmaeng...@vger.kernel.org;
> > linux-kernel@vger.kernel.org; devicet...@vger.kernel.org
> > Subject: [PATCH v8 13/16] dmaengine: dw-axi-dmac: Add Intel
> KeemBay
> > AxiDMA handshake
> >
> > Add support for Intel KeemBay AxiDMA device handshake
> programming.
> > Device handshake number passed in to the AxiDMA shall be written
> to
> > the Intel KeemBay AxiDMA hardware handshake registers before
> DMA
> > operations are started.
> >
> > Reviewed-by: Andy Shevchenko
> 
> > Signed-off-by: Sia Jee Heng 
> > ---
> >  .../dma/dw-axi-dmac/dw-axi-dmac-platform.c| 52
> +++
> >  1 file changed, 52 insertions(+)
> >
> > diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> > b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> > index 062d27c61983..5e77eb3d040f 100644
> > --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> > +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
>  [snip]
> > +
> > +   return 0;
> > +}
> > +
> >  /*
> >   * If DW_axi_dmac sees CHx_CTL.ShadowReg_Or_LLI_Last bit of
> the fetched LLI
> >   * as 1, it understands that the current block is the final block in
> > the @@ -626,6 +668,9 @@ dw_axi_dma_chan_prep_cyclic(struct
> dma_chan *dchan, dma_addr_t dma_addr,
> > llp = hw_desc->llp;
> > } while (num_periods);
> >
> > +   if (dw_axi_dma_set_hw_channel(chan->chip, chan-
> >hw_handshake_num, true))
> > +   goto err_desc_get;
> > +
> 
> In this implementation 'dw_axi_dma_chan_prep_cyclic' callback will
> fail if we don't have APB registers which are only specific for KeemBay.
> Looking for the code of 'dw_axi_dma_chan_prep_cyclic' I don't see
> the reason why it shouldn't work for vanila DW AXI DMAC without this
> extension. So, could you please change this so we wouldn't reject
> dw_axi_dma_chan_prep_cyclic in case of APB registers are missed.
[>>] OK, I can change the code in such a way that dw_axi_dma_set_hw_channel() 
will be executed only if apb_reg is valid.
> 
> > return vchan_tx_prep(>vc, >vd, flags);
> >
> >  err_desc_get:
> > @@ -684,6 +729,9 @@ dw_axi_dma_chan_prep_slave_sg(struct
> dma_chan *dchan, struct scatterlist *sgl,
> > llp = hw_desc->llp;
> > } while (sg_len);
> >
> > +   if (dw_axi_dma_set_hw_channel(chan->chip, chan-
> >hw_handshake_num, true))
> > +   goto err_desc_get;
> > +
> 
> Same here.
[>>] Sure, same method described above will be used.
> 
> 
> > return vchan_tx_prep(>vc, >vd, flags);
> >
> >  err_desc_get:
> > @@ -959,6 +1007,10 @@ static int dma_chan_terminate_all(struct
> dma_chan *dchan)
> > dev_warn(dchan2dev(dchan),
> >  "%s failed to stop\n", axi_chan_name(chan));
> >
> > +   if (chan->direction != DMA_MEM_TO_MEM)
> > +   dw_axi_dma_set_hw_channel(chan->chip,
> > + chan->hw_handshake_num,
> > + false);
> > +
> > spin_lock_irqsave(>vc.lock, flags);
> >
> > vchan_get_all_descriptors(>vc, );
> > --
> > 2.18.0
> >


Re: [PATCH] Input: da7280 - protect OF match table with CONFIG_OF

2021-01-03 Thread Jeff LaBundy
Hi Dmitry,

On Sun, Jan 03, 2021 at 05:58:41PM -0800, Dmitry Torokhov wrote:
> Hi Jeff,
> 
> On Sat, Dec 19, 2020 at 08:01:09PM -0600, Jeff LaBundy wrote:
> > Hi Dmitry,
> > 
> > On Fri, Dec 18, 2020 at 04:49:48PM +, Roy Im wrote:
> > > On Friday, December 18, 2020 3:50 PM, Dmitry Torokhov wrote:
> > > 
> > > > The OF match table is only used when OF is enabled.
> > > > 
> > > > Fixes: cd3f609823a5 ("Input: new da7280 haptic driver")
> > > > Reported-by: kernel test robot 
> > > > Signed-off-by: Dmitry Torokhov 
> > > > ---
> > > >  drivers/input/misc/da7280.c | 2 ++
> > > >  1 file changed, 2 insertions(+)
> > > > 
> > > > diff --git a/drivers/input/misc/da7280.c b/drivers/input/misc/da7280.c 
> > > > index 2f698a8c1d65..b08610d6e575 100644
> > > > --- a/drivers/input/misc/da7280.c
> > > > +++ b/drivers/input/misc/da7280.c
> > > > @@ -1300,11 +1300,13 @@ static int __maybe_unused da7280_resume(struct 
> > > > device *dev)
> > > > return retval;
> > > >  }
> > > > 
> > > > +#ifdef CONFIG_OF
> > > >  static const struct of_device_id da7280_of_match[] = {
> > > > { .compatible = "dlg,da7280", },
> > > > { }
> > > >  };
> > > >  MODULE_DEVICE_TABLE(of, da7280_of_match);
> > > > +#endif
> > 
> > Just for my own understanding, would it not work just as well
> > to include of_device.h? This includes mod_devicetable.h which
> > in turn defines the of_device_id struct (even if CONFIG_OF is
> > not set).
> 
> The issue here is not that the structure is undefined, but the variable
> is unused. We could also fix this by not using of_match_ptr() when
> assigning the match table to the driver structure, making the variable
> referenced even if CONFIG_OF is off.

ACK. The call to of_match_ptr() is what I was missing; the other
drivers I was looking at do not use it which must be why the bot
has not complained.

> 
> > 
> > The reason for asking is because it seems many drivers do not
> > include these guards.
> 
> It could be that they are either only compiled with OF, or they decided
> it is not worth saving a few bytes, or maybe they are used on ACPI-based
> systems with PRP0001 bindings in which case the match table in the
> driver might still be needed.

Makes perfect sense; thank you for the follow-up.

> 
> Thanks.
> 
> -- 
> Dmitry

Kind regards,
Jeff LaBundy


linux-next: Tree for Jan 4

2021-01-03 Thread Stephen Rothwell
Hi all,

Changes since 20201223:

New tree: actions

The rcu tree gained a build failure so I used the version from
next-20201223.

The staging tree gained build failures so I used the version from
next-20201223.

Non-merge commits (relative to Linus' tree): 950
 961 files changed, 35277 insertions(+), 14403 deletions(-)



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

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

Below is a summary of the state of the merge.

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

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

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

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

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (3516bd729358 Merge tag 's390-5.11-3' of 
git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux)
Merging fixes/fixes (9223e74f9960 Merge tag 'io_uring-5.10-2020-11-27' of 
git://git.kernel.dk/linux-block)
Merging kbuild-current/fixes (63e184ea9869 kconfig: remove 'kvmconfig' and 
'xenconfig' shorthands)
Merging arc-current/for-curr (3a71e423133a ARC: build: use $(READELF) instead 
of hard-coded readelf)
Merging arm-current/fixes (e64ab473ddda ARM: 9034/1: __div64_32(): straighten 
up inline asm constraints)
Merging arm64-fixes/for-next/fixes (9fd339a45be5 arm64: Work around broken GCC 
4.9 handling of "S" constraint)
Merging arm-soc-fixes/arm/fixes (7887cc89d585 ARM: dts: ux500/golden: Set 
display max brightness)
Merging drivers-memory-fixes/fixes (5c8fe583cce5 Linux 5.11-rc1)
Merging m68k-current/for-linus (2ae92e8b9b7e MAINTAINERS: Update m68k Mac entry)
Merging powerpc-fixes/fixes (d5c243989fb0 powerpc/32: Fix vmap stack - Properly 
set r1 before activating MMU on syscall too)
Merging s390-fixes/fixes (129975e75b9a s390/Kconfig: sort config S390 select 
list once again)
Merging sparc/master (0a95a6d1a4cd sparc: use for_each_child_of_node() macro)
Merging fscrypt-current/for-stable (d19d8d345eec fscrypt: fix inline encryption 
not used on new files)
Merging net/master (4bfc4714849d Merge 
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf)
Merging bpf/master (04901aab40ea bpf: Fix a task_iter bug caused by a merge 
conflict resolution)
Merging ipsec/master (56ce7c25ae15 xfrm: Fix oops in xfrm_replay_advance_bmp)
Merging netfilter/master (b4e70d8dd9ea netfilter: nftables: add set expression 
flags)
Merging ipvs/master (5c8193f568ae netfilter: ipset: fix shift-out-of-bounds in 
htable_bits())
Merging wireless-drivers/master (bfe55584713b MAINTAINERS: switch to different 
email address)
Merging mac80211/master (2c85ebc57b3e Linux 5.10)
Merging rdma-fixes/for-rc (340b940ea0ed RDMA/cm: Fix an attempt to use 
non-valid pointer when cleaning timewait)
Merging sound-current/for-linus (b0e130630201 ALSA: usb-audio: Add quirk for 
RC-505)
Merging sound-asoc-fixes/for-linus (1f092d1c8819 ASoC: AMD Renoir - add DMI 
entry for Lenovo ThinkPad X395)
Merging regmap-fixes/for-linus (cffa4b2122f5 regmap: debugfs: Fix a memory leak 
when calling regmap_attach_dev)
Merging regulator-fixes/for-linus (2ae6f64ce1ce Merge tag 'v5.11-rc1' into 
regulator-5.11)
Merging spi-fixes/for-linus (6820e812dafb spi: Fix the clamping of 
spi->max_speed_hz)
Merging pci-current/for-linus (5c8fe583cce5 Linux 5.11-rc1)
Merging driver-core.current/driver-core-linus (5c8fe583cce5 Linux 5.11-rc1)
Merging tty.current/tty-linus (54ca955b5a40 serial: mvebu-uart: fix tx lost 
characters at power off)
Merging usb.current/usb-linus (c318840fb2a4 USB: Gadget: dummy-hcd: Fix 
shift-out-of-bounds bug)

Re: [PATCH -tip v2] x86/kprobes: Do not decode opcode in resume_execution()

2021-01-03 Thread Masami Hiramatsu
On Thu, 31 Dec 2020 17:09:23 +0100
Borislav Petkov  wrote:

> On Fri, Dec 18, 2020 at 11:12:05PM +0900, Masami Hiramatsu wrote:
> > @@ -467,8 +489,8 @@ static int arch_copy_kprobe(struct kprobe *p)
> >  */
> > len = prepare_boost(buf, p, );
> >  
> > -   /* Check whether the instruction modifies Interrupt Flag or not */
> > -   p->ainsn.if_modifier = is_IF_modifier(buf);
> > +   /* Analyze the opcode and set resume flags */
> > +   set_resume_flags(p, );
> 
> So this function wants to be called something like analyze_insn() or so
> then? set_resume_flags() is kinda misleading as a name.

Hrm, I meant setting the flags used in the resume_execution() afterwards.
Since the instruction itself (not only opcode but also oprands) was
also analyzed in other places, so I like the set_resume_flags() for it.

Thank you,

-- 
Masami Hiramatsu 


Re: [PATCH v3 03/10] irqchip/sun6i-r: Use a stacked irqchip driver

2021-01-03 Thread Samuel Holland
On 1/3/21 7:10 AM, Marc Zyngier wrote:
> On Sun, 03 Jan 2021 12:08:43 +,
> Samuel Holland  wrote:
>>
>> On 1/3/21 5:27 AM, Marc Zyngier wrote:
>>> On Sun, 03 Jan 2021 10:30:54 +,
>>> Samuel Holland  wrote:

 The R_INTC in the A31 and newer sun8i/sun50i SoCs is more similar to the
 original sun4i interrupt controller than the sun7i/sun9i NMI controller.
 It is used for two distinct purposes:
  - To control the trigger, latch, and mask for the NMI input pin
  - To provide the interrupt input for the ARISC coprocessor

 As this interrupt controller is not documented, information about it
 comes from vendor-provided firmware blobs and from experimentation.

 Like the original sun4i interrupt controller, it has:
  - A VECTOR_REG at 0x00 (configurable via the BASE_ADDR_REG at 0x04)
  - A NMI_CTRL_REG, PENDING_REG, and ENABLE_REG as used by both the
sun4i and sunxi-nmi drivers
  - A MASK_REG at 0x50
  - A RESP_REG at 0x60

 Differences from the sun4i interrupt controller appear to be:
  - It only has one or two registers of each kind (max 32 or 64 IRQs)
  - Multiplexing logic is added to support additional inputs
  - There is no FIQ-related logic
  - There is no interrupt priority logic

 In order to fulfill its two purposes, this hardware block combines four
 types of IRQs. First, the NMI pin is routed to the "IRQ 0" input on this
 chip, with a trigger type controlled by the NMI_CTRL_REG. The "IRQ 0
 pending" output from this chip, if enabled, is then routed to a SPI IRQ
 input on the GIC. In other words, bit 0 of IRQ_ENABLE_REG *does* affect
 the NMI IRQ seen at the GIC.

 The NMI is followed by a contiguous block of 15 "direct" (my name for
 them) IRQ inputs that are connected in parallel to both R_INTC and the
 GIC. Or in other words, these bits of IRQ_ENABLE_REG *do not* affect the
 IRQs seen at the GIC.

 Following the direct IRQs are the ARISC's copy of banked IRQs for shared
 peripherals. These are not relevant to Linux. The remaining IRQs are
 connected to a multiplexer and provide access to the first (up to) 128
 SPIs from the ARISC. This range of SPIs overlaps with the direct IRQs.

 Finally, the global "IRQ pending" output from R_INTC, after being masked
 by MASK_REG and RESP_REG, is connected to the "external interrupt" input
 of the ARISC CPU. This path is also irrelevant to Linux.
>>>
>>> An ASCII-art version of this would help a lot, and would look good in
>>> the driver code...
>>
>> There is this diagram which I forgot to include in the cover letter:
>>
>>   https://linux-sunxi.org/images/5/5c/R_INTC.png
>>
>> I can try to come up with some ASCII art.
>>
 Because of the 1:1 correspondence between R_INTC and GIC inputs, this is
 a perfect scenario for using a stacked irqchip driver. We want to hook
 into enabling/disabling IRQs to add more features to the GIC
 (specifically to allow masking the NMI and setting its trigger type),
 but we don't need to actually handle the IRQ in this driver.

 And since R_INTC is in the always-on power domain, and its output is
 connected directly in to the power management coprocessor, a stacked
 irqchip driver provides a simple way to add wakeup support to this set
 of IRQs. That is the next patch; for now, just the NMI is moved over.

 To allow access to all multiplexed IRQs, this driver requires a new
 binding where the interrupt number matches the GIC interrupt number.
 (This moves the NMI number from 0 to 32 or 96, depending on the SoC.)
 For simplicity, copy the three-cell GIC binding; this disambiguates
 interrupt 0 in the old binding (the NMI) from interrupt 0 in the new
 binding (SPI 0) by the number of cells.

 This commit mostly reverts commit 173bda53b340 ("irqchip/sunxi-nmi:
 Support sun6i-a31-r-intc compatible").

 Signed-off-by: Samuel Holland 
 ---
  arch/arm/mach-sunxi/Kconfig |   1 +
  arch/arm64/Kconfig.platforms|   1 +
  drivers/irqchip/Makefile|   1 +
  drivers/irqchip/irq-sun6i-r.c   | 267 
  drivers/irqchip/irq-sunxi-nmi.c |  26 +---
  5 files changed, 273 insertions(+), 23 deletions(-)
  create mode 100644 drivers/irqchip/irq-sun6i-r.c

>>>
>>> [...]
>>>
 diff --git a/drivers/irqchip/irq-sun6i-r.c b/drivers/irqchip/irq-sun6i-r.c
 new file mode 100644
 index ..7490ade7b254
 --- /dev/null
 +++ b/drivers/irqchip/irq-sun6i-r.c
 @@ -0,0 +1,267 @@
 +// SPDX-License-Identifier: GPL-2.0-only
 +//
 +// R_INTC driver for Allwinner A31 and newer SoCs
 +//
 +
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +
 +#include 
 +
 +/*
 + * The R_INTC manages between 32 and 64 IRQs, 

Re: [PATCH 11/11] dts: bindings: Document device tree binding for Arm TRBE

2021-01-03 Thread Anshuman Khandual


On 1/3/21 10:35 PM, Rob Herring wrote:
> On Wed, Dec 23, 2020 at 03:33:43PM +0530, Anshuman Khandual wrote:
>> This patch documents the device tree binding in use for Arm TRBE.
>>
>> Cc: devicet...@vger.kernel.org
>> Cc: Mathieu Poirier 
>> Cc: Mike Leach 
>> Cc: Suzuki K Poulose 
>> Signed-off-by: Anshuman Khandual 
>> ---
>> Changes in V1:
>>
>> - TRBE DT entry has been renamed as 'arm, trace-buffer-extension'
>>
>>  Documentation/devicetree/bindings/arm/trbe.txt | 20 
>>  1 file changed, 20 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/arm/trbe.txt
>>
>> diff --git a/Documentation/devicetree/bindings/arm/trbe.txt 
>> b/Documentation/devicetree/bindings/arm/trbe.txt
>> new file mode 100644
>> index 000..001945d
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/arm/trbe.txt
>> @@ -0,0 +1,20 @@
>> +* Trace Buffer Extension (TRBE)
>> +
>> +Trace Buffer Extension (TRBE) is used for collecting trace data generated
>> +from a corresponding trace unit (ETE) using an in memory trace buffer.
>> +
>> +** TRBE Required properties:
>> +
>> +- compatible : should be one of:
>> +   "arm,trace-buffer-extension"
>> +
>> +- interrupts : Exactly 1 PPI must be listed. For heterogeneous systems where
>> +   TRBE is only supported on a subset of the CPUs, please consult
>> +   the arm,gic-v3 binding for details on describing a PPI partition.
>> +
>> +** Example:
>> +
>> +trbe {
>> +compatible = "arm,trace-buffer-extension";
>> +interrupts = ;
> 
> If only an interrupt, then could just be part of ETE? If not, how is 
> this hardware block accessed? An interrupt alone is not enough unless 
> there's some architected way to access.

TRBE hardware block is accessed via respective new system registers but the
PPI number where the IRQ will be triggered for various buffer events, would
depend on the platform as defined in the SBSA.

TRBE would need a ETE to work but the reverse is not true. ETE might just
be present without a corresponding TRBE and can work with traditional sinks.
Hence just wondering whether it would be prudent to add the TRBE interrupt
number as part of the ETE DT specification.


[PATCH v2] arm64/ras: Update code to trace out more data for ARM processor

2021-01-03 Thread Jason Tian
The original arm_event trace code only traces out ARM processor
error information data. According to UEFI_2_8_A_Feb14 specification
chapter N2.4.4, the ARM processor error section includes several
ARM processor error information, several ARM processor
context information and several vendor specific error
information structures.

Add code to trace out all ARM processor context information and
vendor specific error information with raw hex format.

Signed-off-by: Jason Tian 
---
 drivers/ras/ras.c   | 22 +-
 include/ras/ras_event.h | 41 +++--
 2 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/drivers/ras/ras.c b/drivers/ras/ras.c
index 3f3890732..a0a6b2f87 100644
--- a/drivers/ras/ras.c
+++ b/drivers/ras/ras.c
@@ -23,7 +23,27 @@ void log_non_standard_event(const uuid_le *sec_type, const 
uuid_le *fru_id,
 
 void log_arm_hw_error(struct cper_sec_proc_arm *err)
 {
-   trace_arm_event(err);
+   u32 pei_len;
+   u32 ctx_len;
+   u32 vsei_len;
+   u8 *pei_err;
+   u8 *ctx_err;
+   u8 *ven_err_data;
+
+   pei_len = sizeof(struct cper_arm_err_info) * err->err_info_num;
+   pei_err = (u8 *) err + sizeof(struct cper_sec_proc_arm);
+
+   ctx_len = sizeof(struct cper_arm_ctx_info) * err->context_info_num;
+   ctx_err = pei_err + sizeof(struct cper_arm_err_info) *
+   err->err_info_num;
+
+   vsei_len = err->section_length - (sizeof(struct cper_sec_proc_arm) +
+ pei_len + ctx_len);
+   ven_err_data = ctx_err + sizeof(struct cper_arm_ctx_info) *
+ err->context_info_num;
+
+   trace_arm_event(err, pei_err, pei_len, ctx_err, ctx_len,
+   ven_err_data, vsei_len);
 }
 
 static int __init ras_init(void)
diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h
index a0794632f..7b1082774 100644
--- a/include/ras/ras_event.h
+++ b/include/ras/ras_event.h
@@ -168,11 +168,22 @@ TRACE_EVENT(mc_event,
  * This event is generated when hardware detects an ARM processor error
  * has occurred. UEFI 2.6 spec section N.2.4.4.
  */
+ #define APEIL "ARM Processor Err Info data len"
+ #define APEID "ARM Processor Err Info raw data"
+ #define APECIL "ARM Processor Err Context Info data len"
+ #define APECID "ARM Processor Err Context Info raw data"
+ #define VSEIL "Vendor Specific Err Info data len"
+ #define VSEID "Vendor Specific Err Info raw data"
 TRACE_EVENT(arm_event,
 
-   TP_PROTO(const struct cper_sec_proc_arm *proc),
+   TP_PROTO(const struct cper_sec_proc_arm *proc, const u8 *pei_err,
+   const u32 pei_len,
+   const u8 *ctx_err,
+   const u32 ctx_len,
+   const u8 *oem,
+   const u32 oem_len),
 
-   TP_ARGS(proc),
+   TP_ARGS(proc, pei_err, pei_len, ctx_err, ctx_len, oem, oem_len),
 
TP_STRUCT__entry(
__field(u64, mpidr)
@@ -180,6 +191,12 @@ TRACE_EVENT(arm_event,
__field(u32, running_state)
__field(u32, psci_state)
__field(u8, affinity)
+   __field(u32, pei_len)
+   __dynamic_array(u8, buf, pei_len)
+   __field(u32, ctx_len)
+   __dynamic_array(u8, buf1, ctx_len)
+   __field(u32, oem_len)
+   __dynamic_array(u8, buf2, oem_len)
),
 
TP_fast_assign(
@@ -199,12 +216,24 @@ TRACE_EVENT(arm_event,
__entry->running_state = ~0;
__entry->psci_state = ~0;
}
+   __entry->pei_len = pei_len;
+   memcpy(__get_dynamic_array(buf), pei_err, pei_len);
+   __entry->ctx_len = ctx_len;
+   memcpy(__get_dynamic_array(buf1), ctx_err, ctx_len);
+   __entry->oem_len = oem_len;
+   memcpy(__get_dynamic_array(buf2), oem, oem_len);
),
 
-   TP_printk("affinity level: %d; MPIDR: %016llx; MIDR: %016llx; "
- "running state: %d; PSCI state: %d",
- __entry->affinity, __entry->mpidr, __entry->midr,
- __entry->running_state, __entry->psci_state)
+   TP_printk("affinity level: %d; MPIDR: %016llx; MIDR: %016llx; running 
state: %d; "
+   "PSCI state: %d; %s: %d; %s: %s; %s: %d; %s: %s; %s: %d; %s: 
%s",
+   __entry->affinity, __entry->mpidr, __entry->midr,
+   __entry->running_state, __entry->psci_state,
+   APEIL, __entry->pei_len, APEID,
+   __print_hex(__get_dynamic_array(buf), __entry->pei_len),
+   APECIL, __entry->ctx_len, APECID,
+   __print_hex(__get_dynamic_array(buf1), __entry->ctx_len),
+   VSEIL, __entry->oem_len, VSEID,
+   __print_hex(__get_dynamic_array(buf2), __entry->oem_len))
 );
 
 /*
-- 
2.25.1



Re: [PATCH V2 19/19] vdpa: introduce virtio pci driver

2021-01-03 Thread Jason Wang



On 2020/12/4 下午11:20, Stefano Garzarella wrote:

+#define VP_VDPA_QUEUE_MAX 256
+#define VP_VDPA_DRIVER_NAME "vp_vdpa"
+
+struct vp_vring {
+    void __iomem *notify;
+    char msix_name[256];


Can we use a macro for the msix_name size, since we use 256 in 
multiple places?



Yes, will switch to use a macro.





+    struct vdpa_callback cb;
+    int irq;
+};
+
+struct vp_vdpa {
+    struct vdpa_device vdpa;
+    struct virtio_pci_modern_device mdev;
+    struct vp_vring *vring;
+    struct vdpa_callback cb;

 ^
It is not relevant, but 'config_cb' is maybe clearer to read.



Will change to config_cb.



The rest looks good.



Thanks




Thanks,
Stefano 




Re: [PATCH V2 16/19] virtio-pci: introduce modern device module

2021-01-03 Thread Jason Wang



On 2020/12/5 上午1:10, Randy Dunlap wrote:

Hi Jason--

On 12/3/20 8:03 PM, Jason Wang wrote:

diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
index 7b41130d3f35..d1a6bd2a975f 100644
--- a/drivers/virtio/Kconfig
+++ b/drivers/virtio/Kconfig
@@ -12,6 +12,14 @@ config ARCH_HAS_RESTRICTED_VIRTIO_MEMORY_ACCESS
  This option is selected if the architecture may need to enforce
  VIRTIO_F_ACCESS_PLATFORM
  
+config VIRTIO_PCI_MODERN

+   tristate "Modern Virtio PCI Device"
+   depends on PCI
+   help
+ Modern PCI device implementation. This module implement the

implements


+ basic probe and control for devices which is based on modern

are


+ PCI device with possible vendor specific extensions.

  devices

+


cheers.



All fixed.

Thanks




Re: [PATCH v3, 1/8] soc: mediatek: mmsys: create mmsys folder

2021-01-03 Thread Yongqiang Niu
On Thu, 2020-12-31 at 09:21 +0800, Nicolas Boichat wrote:
> On Mon, Dec 28, 2020 at 4:38 PM Yongqiang Niu
>  wrote:
> >
> > the mmsys will more and more complicated after support
> > more and more SoCs, add an independent folder will be
> > more clear
> >
> > Signed-off-by: Yongqiang Niu 
> > ---
> >  drivers/soc/mediatek/Makefile  |   2 +-
> >  drivers/soc/mediatek/mmsys/Makefile|   2 +
> >  drivers/soc/mediatek/mmsys/mtk-mmsys.c | 380 
> > +
> >  drivers/soc/mediatek/mtk-mmsys.c   | 380 
> > -
> 
> I wonder why this doesn't get detected as a rename?

the rename message displayed when git commit -s
git show will not show the rename information

> 
> >  4 files changed, 383 insertions(+), 381 deletions(-)
> >  create mode 100644 drivers/soc/mediatek/mmsys/Makefile
> >  create mode 100644 drivers/soc/mediatek/mmsys/mtk-mmsys.c
> >  delete mode 100644 drivers/soc/mediatek/mtk-mmsys.c
> >
> > diff --git a/drivers/soc/mediatek/Makefile b/drivers/soc/mediatek/Makefile
> > index 01f9f87..b5987ca 100644
> > --- a/drivers/soc/mediatek/Makefile
> > +++ b/drivers/soc/mediatek/Makefile
> > @@ -3,4 +3,4 @@ obj-$(CONFIG_MTK_CMDQ) += mtk-cmdq-helper.o
> >  obj-$(CONFIG_MTK_INFRACFG) += mtk-infracfg.o
> >  obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap.o
> >  obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o
> > -obj-$(CONFIG_MTK_MMSYS) += mtk-mmsys.o
> > +obj-$(CONFIG_MTK_MMSYS) += mmsys/
> > diff --git a/drivers/soc/mediatek/mmsys/Makefile 
> > b/drivers/soc/mediatek/mmsys/Makefile
> > new file mode 100644
> > index 000..5d976d7
> > --- /dev/null
> > +++ b/drivers/soc/mediatek/mmsys/Makefile
> > @@ -0,0 +1,2 @@
> > +# SPDX-License-Identifier: GPL-2.0-only
> > +obj-$(CONFIG_MTK_MMSYS) += mtk-mmsys.o
> > \ No newline at end of file
> 
> Nit: newline at end of file please.

it will be fixed in next version



Re: [PATCH 2/2] mm: memcg: add a new MEMCG_UPDATE_BATCH

2021-01-03 Thread Feng Tang
Hi Roman,

On Tue, Dec 29, 2020 at 09:13:27AM -0800, Roman Gushchin wrote:
> On Tue, Dec 29, 2020 at 10:35:14PM +0800, Feng Tang wrote:
> > When profiling memory cgroup involved benchmarking, status update
> > sometimes take quite some CPU cycles. Current MEMCG_CHARGE_BATCH
> > is used for both charging and statistics/events updating, and is
> > set to 32, which may be good for accuracy of memcg charging, but
> > too small for stats update which causes concurrent access to global
> > stats data instead of per-cpu ones.
> > 
> > So handle them differently, by adding a new bigger batch number
> > for stats updating, while keeping the value for charging (though
> > comments in memcontrol.h suggests to consider a bigger value too)
> > 
> > The new batch is set to 512, which considers 2MB huge pages (512
> > pages), as the check logic mostly is:
> > 
> > if (x > BATCH), then skip updating global data
> > 
> > so it will save 50% global data updating for 2MB pages
> > 
> > Following are some performance data with the patch, against
> > v5.11-rc1, on several generations of Xeon platforms. Each category
> > below has several subcases run on different platform, and only the
> > worst and best scores are listed:
> > 
> > fio: +2.0% ~  +6.8%
> > will-it-scale/malloc:-0.9% ~  +6.2%
> > will-it-scale/page_fault1:   no change
> > will-it-scale/page_fault2:  +13.7% ~ +26.2%
> 
> I wonder if there are any wins noticeable in the real world?
> Lowering the accuracy of statistics makes harder to interpret it,
> so it should be very well justified.

This is a valid concern. I only had test results for fio, 
will-it-scale and vm-scalability (mostly impovements) so far, 
and I will try to run on some Redis/RockDB like workload. I have
seen hotspots related with memcg statistics counting in some
customers' report, which is part of the motivation of the patch. 

> 512 * nr_cpus is a large number.

I also tested 128, 256, 2048, 4096, which all show similar gains
with the benchmarks above, and 512 is chosed for 2MB pages. 128
could be less harmful for accuracy.

> > 
> > One thought is it could be dynamically calculated according to
> > memcg limit and number of CPUs, and another is to add a periodic
> > syncing of the data for accuracy reason similar to vmstat, as
> > suggested by Ying.
> 
> It sounds good to me, but it's quite tricky to implement properly,
> given that thee number of cgroups can be really big. It makes the
> traversing of the whole cgroup tree and syncing stats quite expensive,
> so it will not be easy to find a good balance.

Agreed. Also could you shed some light about how these statistics
data are used, so that we can better understand the usage.

Thanks again for the valuable feedback! 

- Feng

> Thanks!


drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c:2060:20: warning: stack frame size of 2496 bytes in function 'mcp251xfd_irq'

2021-01-03 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   e71ba9452f0b5b2e8dc8aa5445198cd9214a6a62
commit: eb79a267c9b3e608e7762a1b221428f37ace3aa3 can: mcp251xfd: rename all 
remaining occurrence to mcp251xfd
date:   3 months ago
config: powerpc64-randconfig-r021-20210104 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 
98cd1c33e3c2c3cfee36fb0fea3285fda06224d3)
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 powerpc64 cross compiling tool for clang build
# apt-get install binutils-powerpc64-linux-gnu
# 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eb79a267c9b3e608e7762a1b221428f37ace3aa3
git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout eb79a267c9b3e608e7762a1b221428f37ace3aa3
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross 
ARCH=powerpc64 

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

All warnings (new ones prefixed by >>):

   drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c:511:1: warning: unused 
function 'mcp251xfd_chip_set_mode_nowait' [-Wunused-function]
   mcp251xfd_chip_set_mode_nowait(const struct mcp251xfd_priv *priv,
   ^
>> drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c:2060:20: warning: stack frame 
>> size of 2496 bytes in function 'mcp251xfd_irq' [-Wframe-larger-than=]
   static irqreturn_t mcp251xfd_irq(int irq, void *dev_id)
  ^
   2 warnings generated.

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for HOTPLUG_PCI_POWERNV
   Depends on PCI && HOTPLUG_PCI && PPC_POWERNV && EEH
   Selected by
   - OCXL && PPC_POWERNV && PCI && EEH


vim +/mcp251xfd_irq +2060 drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c

  2059  
> 2060  static irqreturn_t mcp251xfd_irq(int irq, void *dev_id)
  2061  {
  2062  struct mcp251xfd_priv *priv = dev_id;
  2063  irqreturn_t handled = IRQ_NONE;
  2064  int err;
  2065  
  2066  if (priv->rx_int)
  2067  do {
  2068  int rx_pending;
  2069  
  2070  rx_pending = 
gpiod_get_value_cansleep(priv->rx_int);
  2071  if (!rx_pending)
  2072  break;
  2073  
  2074  err = mcp251xfd_handle(priv, rxif);
  2075  if (err)
  2076  goto out_fail;
  2077  
  2078  handled = IRQ_HANDLED;
  2079  } while (1);
  2080  
  2081  do {
  2082  u32 intf_pending, intf_pending_clearable;
  2083  bool set_normal_mode = false;
  2084  
  2085  err = regmap_bulk_read(priv->map_reg, MCP251XFD_REG_INT,
  2086 >regs_status,
  2087 sizeof(priv->regs_status) /
  2088 sizeof(u32));
  2089  if (err)
  2090  goto out_fail;
  2091  
  2092  intf_pending = FIELD_GET(MCP251XFD_REG_INT_IF_MASK,
  2093   priv->regs_status.intf) &
  2094  FIELD_GET(MCP251XFD_REG_INT_IE_MASK,
  2095priv->regs_status.intf);
  2096  
  2097  if (!(intf_pending))
  2098  return handled;
  2099  
  2100  /* Some interrupts must be ACKed in the
  2101   * MCP251XFD_REG_INT register.
  2102   * - First ACK then handle, to avoid lost-IRQ race
  2103   *   condition on fast re-occurring interrupts.
  2104   * - Write "0" to clear active IRQs, "1" to all other,
  2105   *   to avoid r/m/w race condition on the
  2106   *   MCP251XFD_REG_INT register.
  2107   */
  2108  intf_pending_clearable = intf_pending &
  2109  MCP251XFD_REG_INT_IF_CLEARABLE_MASK;
  2110  if (intf_pending_clearable) {
  2111  err = regmap_update_bits(priv->map_reg,
  2112   MCP251XFD_REG_INT,
  2113   
MCP251XFD_REG_INT_IF_MASK,
  2114   
~intf_pending_clearable);
  2115  if (err)
  2116  goto out_fail;
  2117  }
  2118  
  2119  if 

[PATCH] Documentation/dax: Update description of DAX policy changing

2021-01-03 Thread Hao Li
After commit 77573fa310d9 ("fs: Kill DCACHE_DONTCACHE dentry even if
DCACHE_REFERENCED is set"), changes to DAX policy will take effect
as soon as all references to this file are gone.

Update the documentation accordingly.

Signed-off-by: Hao Li 
---
 Documentation/filesystems/dax.txt | 15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/Documentation/filesystems/dax.txt 
b/Documentation/filesystems/dax.txt
index 8fdb78f3c6c9..a5af22831087 100644
--- a/Documentation/filesystems/dax.txt
+++ b/Documentation/filesystems/dax.txt
@@ -84,19 +84,8 @@ Summary
described in 6) below.
 
  6. When changing the S_DAX policy via toggling the persistent FS_XFLAG_DAX 
flag,
-the change in behaviour for existing regular files may not occur
-immediately.  If the change must take effect immediately, the administrator
-needs to:
-
-a) stop the application so there are no active references to the data set
-   the policy change will affect
-
-b) evict the data set from kernel caches so it will be re-instantiated when
-   the application is restarted. This can be achieved by:
-
-   i. drop-caches
-   ii. a filesystem unmount and mount cycle
-   iii. a system reboot
+the change to existing regular file won't take effect until the file is 
closed
+by all processes or all processes referencing the file are stopped.
 
 
 Details
-- 
2.29.2





[PATCH v2] perf stat: Append to default list if use -e +event

2021-01-03 Thread Jin Yao
The default event list includes the most common events which are widely
used by users. But with -e option, the current perf only counts the events
assigned by -e option. Users may want to collect some extra events with
the default list. For this case, users have to manually add all the events
from the default list. It's inconvenient. Also, users may don't know how to
get the default list.

Now it supports a simple syntax: -e +event

The prefix '+' tells perf to append this event (or event list) to default
event list.

Before:

root@kbl-ppc:~# ./perf stat -e power/energy-pkg/ -a -- sleep 1

 Performance counter stats for 'system wide':

  2.04 Joules power/energy-pkg/

   1.000863884 seconds time elapsed

After:

root@kbl-ppc:~# ./perf stat -e +power/energy-pkg/ -a -- sleep 1

 Performance counter stats for 'system wide':

  2.11 Joules +power/energy-pkg/#0.000 K/sec
  8,007.17 msec   cpu-clock #7.993 CPUs utilized
   125context-switches  #0.016 K/sec
 8cpu-migrations#0.001 K/sec
 2page-faults   #0.000 K/sec
 8,520,084cycles#0.001 GHz
 2,808,302instructions  #0.33  insn per cycle
   555,427branches  #0.069 M/sec
59,005branch-misses #   10.62% of all branches

   1.001832003 seconds time elapsed

Signed-off-by: Jin Yao 
---
 v2:
   We just use a simple syntax: -e +event to append the -e event
   to default list.

 v1: 
   Create a new option '--add-default' to append -e event to
   default list.

 tools/perf/Documentation/perf-stat.txt |  1 +
 tools/perf/builtin-stat.c  |  3 ++-
 tools/perf/util/evlist.c   | 10 ++
 tools/perf/util/evlist.h   |  1 +
 4 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-stat.txt 
b/tools/perf/Documentation/perf-stat.txt
index 5d4a673d7621..f60af902b8e1 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -63,6 +63,7 @@ report::
Multiple PMU instances are typical for uncore PMUs, so the prefix
'uncore_' is also ignored when performing this match.
 
+   If the prefix '+' is used, the event is appended to default event list.
 
 -i::
 --no-inherit::
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 8cc24967bc27..8400953473ef 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1763,7 +1763,8 @@ static int add_default_attributes(void)
free(str);
}
 
-   if (!evsel_list->core.nr_entries) {
+   if (!evsel_list->core.nr_entries ||
+   evlist__append_default_list(evsel_list)) {
if (target__has_cpu())
default_attrs0[0].config = PERF_COUNT_SW_CPU_CLOCK;
 
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 05363a7247c4..fceef4e57964 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -2010,3 +2010,13 @@ struct evsel *evlist__find_evsel(struct evlist *evlist, 
int idx)
}
return NULL;
 }
+
+bool evlist__append_default_list(struct evlist *evlist)
+{
+   struct evsel *first = evlist__first(evlist);
+
+   if (first->name && first->name[0] == '+')
+   return true;
+
+   return false;
+}
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 1aae75895dea..54592bd22bc2 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -353,4 +353,5 @@ int evlist__ctlfd_ack(struct evlist *evlist);
 #define EVLIST_DISABLED_MSG "Events disabled\n"
 
 struct evsel *evlist__find_evsel(struct evlist *evlist, int idx);
+bool evlist__append_default_list(struct evlist *evlist);
 #endif /* __PERF_EVLIST_H */
-- 
2.17.1



Re: [PATCH v17 04/10] fs/ntfs3: Add file operations and implementation

2021-01-03 Thread Matthew Wilcox
On Thu, Dec 31, 2020 at 06:23:55PM +0300, Konstantin Komarov wrote:
> +/*
> + * file_operations::iterate_shared
> + *
> + * Use non sorted enumeration.
> + * We have an example of broken volume where sorted enumeration
> + * counts each name twice
> + */
> +static int ntfs_readdir(struct file *file, struct dir_context *ctx)
> +{
> + const struct INDEX_ROOT *root;
> + u64 vbo;
> + size_t bit;
> + loff_t eod;
> + int err = 0;
> + struct inode *dir = file_inode(file);
> + struct ntfs_inode *ni = ntfs_i(dir);
> + struct super_block *sb = dir->i_sb;
> + struct ntfs_sb_info *sbi = sb->s_fs_info;
> + loff_t i_size = i_size_read(dir);
> + u32 pos = ctx->pos;
> + u8 *name = NULL;
> + struct indx_node *node = NULL;
> + u8 index_bits = ni->dir.index_bits;
> +
> + /* name is a buffer of PATH_MAX length */
> + static_assert(NTFS_NAME_LEN * 4 < PATH_MAX);
> +
> + eod = i_size + sbi->record_size;
> +
> + if (pos >= eod)
> + return 0;
> +
> + if (!dir_emit_dots(file, ctx))
> + return 0;
> +
> + /* allocate PATH_MAX bytes */
> + name = __getname();
> + if (!name)
> + return -ENOMEM;
> +
> + ni_lock(ni);

What is this lock protecting?



Re: [PATCH] staging: greybus: fix stack size warning with UBSAN

2021-01-03 Thread Alex Elder

On 1/3/21 4:35 PM, Arnd Bergmann wrote:

From: Arnd Bergmann 

clang warns about excessive stack usage in this driver when
UBSAN is enabled:

drivers/staging/greybus/audio_topology.c:977:12: error: stack frame size of 
1836 bytes in function 'gbaudio_tplg_create_widget' 
[-Werror,-Wframe-larger-than=]

Rework this code to no longer use compound literals for
initializing the structure in each case, but instead keep
the common bits in a preallocated constant array and copy
them as needed.


This is good, but I have a few comments.

You took out the default case, and it seems you are using
a w->type value bigger than the initialization array to
determine validity.  But there are more values defined in
the snd_soc_dapm_type enumerated type than are explicitly
listed as cases in the switch statement.  So the switch
statement no longer treats some types as invalid (such
as snd_soc_dapm_demux).  Am I missing something?

You are setting explicit names, such as "spk", "hp",
"mic", etc. in the initialization array.  But you
update the name after (struct) assigning from the
array.  I have no real objection I guess, but why
bother?  Why not just use null pointers in the
initialization array?

You change a semicolon to a comma in one spot, and you
should not have.  I'll point that out below.

I like that you got rid of the type casts, which were
apparently unnecessary.

You dropped the break in the final case in the switch
statement, but in an earlier discussion I think we
concluded that wasn't a problem.

I guess the main thing is the first thing mentioned.


Thanks.

-Alex


Signed-off-by: Arnd Bergmann 
---
  drivers/staging/greybus/audio_topology.c | 106 ++-
  1 file changed, 47 insertions(+), 59 deletions(-)

diff --git a/drivers/staging/greybus/audio_topology.c 
b/drivers/staging/greybus/audio_topology.c
index 96b8b29fe899..c03873915c20 100644
--- a/drivers/staging/greybus/audio_topology.c
+++ b/drivers/staging/greybus/audio_topology.c
@@ -974,6 +974,44 @@ static int gbaudio_widget_event(struct snd_soc_dapm_widget 
*w,
return ret;
  }
  
+static const struct snd_soc_dapm_widget gbaudio_widgets[] = {

+   [snd_soc_dapm_spk]  = SND_SOC_DAPM_SPK("spk", gbcodec_event_spk),
+   [snd_soc_dapm_hp]   = SND_SOC_DAPM_HP("hp", gbcodec_event_hp),
+   [snd_soc_dapm_mic]  = SND_SOC_DAPM_MIC("mic", 
gbcodec_event_int_mic),


. . .


@@ -1050,78 +1088,28 @@ static int gbaudio_tplg_create_widget(struct 
gbaudio_module_info *module,
strlcpy(temp_name, w->name, NAME_SIZE);
snprintf(w->name, NAME_SIZE, "GB %d %s", module->dev_id, temp_name);
  
+	if (w->type > ARRAY_SIZE(gbaudio_widgets)) {

+   ret = -EINVAL;
+   goto error;
+   }
+   *dw = gbaudio_widgets[w->type];
+   dw->name = w->name;
+
switch (w->type) {
case snd_soc_dapm_spk:
-   *dw = (struct snd_soc_dapm_widget)
-   SND_SOC_DAPM_SPK(w->name, gbcodec_event_spk);
module->op_devices |= GBAUDIO_DEVICE_OUT_SPEAKER;
break;
case snd_soc_dapm_hp:
-   *dw = (struct snd_soc_dapm_widget)
-   SND_SOC_DAPM_HP(w->name, gbcodec_event_hp);
module->op_devices |= (GBAUDIO_DEVICE_OUT_WIRED_HEADSET
-   | GBAUDIO_DEVICE_OUT_WIRED_HEADPHONE);
+   | GBAUDIO_DEVICE_OUT_WIRED_HEADPHONE),


Please fix this (above) to preserve the original semicolon.


module->ip_devices |= GBAUDIO_DEVICE_IN_WIRED_HEADSET;
break;
case snd_soc_dapm_mic:
-   *dw = (struct snd_soc_dapm_widget)
-   SND_SOC_DAPM_MIC(w->name, gbcodec_event_int_mic);
module->ip_devices |= GBAUDIO_DEVICE_IN_BUILTIN_MIC;
break;


. . .


Re: [PATCH v2 00/11] perf c2c: Sort cacheline with all loads

2021-01-03 Thread Leo Yan
On Sun, Jan 03, 2021 at 11:52:19PM +0100, Jiri Olsa wrote:
> On Sun, Dec 13, 2020 at 01:38:39PM +, Leo Yan wrote:
> > This patch set is to sort cache line for all load operations which hit
> > any cache levels.  For single cache line view, it shows the load
> > references for loads with cache hits and with cache misses respectively.
> > 
> > This series is a following for the old patch set "perf c2c: Sort
> > cacheline with LLC load" [1], in the old patch set it tries to sort
> > cache line with the load operations in last level cache (LLC), after
> > testing we found the trace data doesn't contain LLC events if the
> > platform isn't a NUMA system.  For this reason, this series refines the
> > implementation to sort on all cache levels hits of load operations; it's
> > reasonable for us to review the load and store opreations, if detects
> > any cache line is accessed by multi-threads, this hints that the cache
> > line is possible for false sharing.
> > 
> > This patch set is clearly applied on perf/core branch with the latest
> > commit db0ea13cc741 ("perf evlist: Use the right prefix for 'struct
> > evlist' record methods").  And the changes has been tested on x86 and
> > Arm64, the testing result is shown as below.
> 
> SNIP
> 
> > 
> > 
> >   [...]
> > 
> > Changes from v1:
> > * Changed from sorting on LLC to sorting on all loads with cache hits;
> > * Added patches 06/11, 07/11 for refactoring macros;
> > * Added patch 08/11 for refactoring node header, so can display "%loads"
> >   rather than "%hitms" in the header;
> > * Added patch 09/11 to add local pointers for pointing to output metrics
> >   string and sort string (Juri);
> > * Added warning in percent_hitm() for the display "all", which should
> >   never happen (Juri).
> > 
> > [1] https://lore.kernel.org/patchwork/cover/1321514/
> > 
> > 
> > Leo Yan (11):
> >   perf c2c: Add dimensions for total load hit
> >   perf c2c: Add dimensions for load hit
> >   perf c2c: Add dimensions for load miss
> >   perf c2c: Rename for shared cache line stats
> >   perf c2c: Refactor hist entry validation
> >   perf c2c: Refactor display filter macro
> >   perf c2c: Refactor node display macro
> >   perf c2c: Refactor node header
> >   perf c2c: Add local variables for output metrics
> >   perf c2c: Sort on all cache hit for load operations
> >   perf c2c: Update documentation for display option 'all'
> > 
> >  tools/perf/Documentation/perf-c2c.txt |  21 +-
> >  tools/perf/builtin-c2c.c  | 548 ++
> >  2 files changed, 487 insertions(+), 82 deletions(-)
> 
> Joe might want to test it first, but it looks all good to me:
> 
> Acked-by: Jiri Olsa 

Thanks for the review, Jiri.

Note, after testing with Arm SPE, we found the store operations don't
contain the information for L1 cache hit or miss, this leads to there
have no statistics for "st_l1hit" and "st_l1miss"; finally the single
cache line view only can show the load samples and fails to show store
opreations due to the empty statistics for "st_l1hit" and "st_l1miss".

This is related the hardware issue, after some discussion internally,
so far cannot find a easy way to set memory flag for L1 cache hit or
miss for store operations (more specific, set flags PERF_MEM_LVL_HIT or
PERF_MEM_LVL_MISS for store's L1 cache accessing).

Given it is uncertain for this issue, please hold on for this patch
series and I will resend if have any conclusion.

And really sorry I notify this too late.

Thanks,
Leo


[PATCH] pcmcia: Switch to using the new API kobj_to_dev()

2021-01-03 Thread Tian Tao
fixed the following coccicheck:
drivers/pcmcia/cistpl.c:1557:54-55: WARNING opportunity for kobj_to_dev()
drivers/pcmcia/cistpl.c:1584:53-54: WARNING opportunity for kobj_to_dev()

Signed-off-by: Tian Tao 
---
 drivers/pcmcia/cistpl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index cf109d9..e693910 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -1554,7 +1554,7 @@ static ssize_t pccard_show_cis(struct file *filp, struct 
kobject *kobj,
if (off + count > size)
count = size - off;
 
-   s = to_socket(container_of(kobj, struct device, kobj));
+   s = to_socket(kobj_to_dev(kobj));
 
if (!(s->state & SOCKET_PRESENT))
return -ENODEV;
@@ -1581,7 +1581,7 @@ static ssize_t pccard_store_cis(struct file *filp, struct 
kobject *kobj,
if (error)
return error;
 
-   s = to_socket(container_of(kobj, struct device, kobj));
+   s = to_socket(kobj_to_dev(kobj));
 
if (off)
return -EINVAL;
-- 
2.7.4



  1   2   3   4   >