6.7.11-rc1 review
Subsystems (12)
Sasha Levin
maintainerPATCH 560/713 ALSA: hda/tas2781: do not call pm_runtime_force_* in system_resume/suspend
In reply to Sasha LevinFrom: Gergo Koteles <[email protected]>
[ Upstream commit 5f51de7e30c7282162a631af8a425b54a4576346 ]
The runtime_resume function calls prmg_load and apply_calibration functions, but system_resume also calls them, so calling pm_runtime_force_resume before reset is unnecessary.
For consistency, do not call the pm_runtime_force_suspend in system_suspend, as runtime_suspend does the same.
Message-ID: <d0b4cc1248b9d375d59c009563da42d60d69eac3.1709918447.git.soyer@irl.hu>
--- sound/pci/hda/tas2781_hda_i2c.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
sound/pci/hda/tas2781_hda_i2c.c +1 -10
@@ -781,14 +781,9 @@ static int tas2781_runtime_resume(struct device *dev)static int tas2781_system_suspend (struct device *dev) {struct tas2781_hda *tas_hda =dev_get_drvdata (dev); -int ret;dev_dbg (tas_hda->priv->dev,"System Suspend\n" ); - ret =pm_runtime_force_suspend (dev); -if (ret) -return ret; -mutex_lock (&tas_hda->priv->codec_lock);/* Shutdown chip before system suspend */
@@ -806,14 +801,10 @@ static int tas2781_system_suspend(struct device *dev)static int tas2781_system_resume (struct device *dev) {struct tas2781_hda *tas_hda =dev_get_drvdata (dev); -int i, ret; +int i;dev_dbg (tas_hda->priv->dev,"System Resume\n" ); - ret =pm_runtime_force_resume (dev); -if (ret) -return ret; -mutex_lock (&tas_hda->priv->codec_lock);for (i =0 ; i < tas_hda->priv->ndev; i++) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 561/713 ALSA: hda/tas2781: configure the amp after firmware load
In reply to Sasha LevinFrom: Gergo Koteles <[email protected]>
[ Upstream commit 68f7f3ff6c2a0998be9dc07622bd0d16fd1fda20 ]
Make the amp available immediately after a module load to avoid having to wait for a PCM hook action. (eg. unloading & loading the module while listening music)
Stable-dep-of: 9fc91a6fe37c ("ALSA: hda/tas2781: restore power state after system_resume")
--- sound/pci/hda/tas2781_hda_i2c.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/hda/tas2781_hda_i2c.c +2 -0
@@ -584,6 +584,8 @@ static void tasdev_fw_ready(const struct firmware *fmw, void *context)*/ tasdevice_save_calibration (tas_priv); +tasdevice_tuning_switch (tas_hda->priv,0 ); + out:mutex_unlock (&tas_hda->priv->codec_lock);if (fmw)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 562/713 ALSA: hda/tas2781: restore power state after system_resume
In reply to Sasha LevinFrom: Gergo Koteles <[email protected]>
[ Upstream commit 9fc91a6fe37c78ef301aed4251f7e50b8524e72d ]
After system_resume the amplifers will remain off, even if they were on before system_suspend.
Use playback_started bool to save the playback state, and restore power state based on it.
Message-ID: <1742b61901781826f6e6212ffe1d21af542d134a.1709918447.git.soyer@irl.hu>
--- sound/pci/hda/tas2781_hda_i2c.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
sound/pci/hda/tas2781_hda_i2c.c +12 -1
@@ -142,11 +142,13 @@ static void tas2781_hda_playback_hook(struct device *dev, int action)pm_runtime_get_sync (dev);mutex_lock (&tas_hda->priv->codec_lock);tasdevice_tuning_switch (tas_hda->priv,0 ); + tas_hda->priv->playback_started = true;mutex_unlock (&tas_hda->priv->codec_lock);break ;case HDA_GEN_PCM_ACT_CLOSE :mutex_lock (&tas_hda->priv->codec_lock);tasdevice_tuning_switch (tas_hda->priv,1 ); + tas_hda->priv->playback_started = false;mutex_unlock (&tas_hda->priv->codec_lock);pm_runtime_mark_last_busy (dev);
@@ -585,6 +587,7 @@ static void tasdev_fw_ready(const struct firmware *fmw, void *context)tasdevice_save_calibration (tas_priv);tasdevice_tuning_switch (tas_hda->priv,0 ); + tas_hda->priv->playback_started = true; out:mutex_unlock (&tas_hda->priv->codec_lock);
@@ -750,6 +753,9 @@ static int tas2781_runtime_suspend(struct device *dev)mutex_lock (&tas_hda->priv->codec_lock); +/* The driver powers up the amplifiers at module load time. +* Stop the playback if it's unused. +*/ if (tas_hda->priv->playback_started) {tasdevice_tuning_switch (tas_hda->priv,1 ); tas_hda->priv->playback_started = false;
@@ -789,7 +795,8 @@ static int tas2781_system_suspend(struct device *dev)mutex_lock (&tas_hda->priv->codec_lock);/* Shutdown chip before system suspend */ -tasdevice_tuning_switch (tas_hda->priv,1 ); +if (tas_hda->priv->playback_started) +tasdevice_tuning_switch (tas_hda->priv,1 );mutex_unlock (&tas_hda->priv->codec_lock);
@@ -821,6 +828,10 @@ static int tas2781_system_resume(struct device *dev)* calibrated data inside algo. */ tasdevice_apply_calibration (tas_hda->priv); + +if (tas_hda->priv->playback_started) +tasdevice_tuning_switch (tas_hda->priv,0 ); +mutex_unlock (&tas_hda->priv->codec_lock);return 0 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 563/713 ALSA: usb-audio: Stop parsing channels bits when all channels are found.
In reply to Sasha LevinFrom: Johan Carlsson <[email protected]>
[ Upstream commit a39d51ff1f52cd0b6fe7d379ac93bd8b4237d1b7 ]
If a usb audio device sets more bits than the amount of channels it could write outside of the map array.
Message-ID: <[email protected]>
--- sound/usb/stream.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
sound/usb/stream.c +4 -1
@@ -300,9 +300,12 @@ static struct snd_pcm_chmap_elem *convert_chmap(int channels, unsigned int bits, c =0 ;if (bits) { -for (; bits && *maps; maps++, bits >>=1 ) +for (; bits && *maps; maps++, bits >>=1 ) {if (bits &1 ) chmap->map[c++] = *maps; +if (c == chmap->channels) +break ; + } }else {/* If we're missing wChannelConfig, then guess something to make sure the channel map is not skipped entirely */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 564/713 scsi: hisi_sas: Fix a deadlock issue related to automatic dump
In reply to Sasha LevinFrom: Yihang Li <[email protected]>
[ Upstream commit 3c4f53b2c341ec6428b98cb51a89a09b025d0953 ]
If we issue a disabling PHY command, the device attached with it will go offline, if a 2 bit ECC error occurs at the same time, a hung task may be found:
[ 4613.652388] INFO: task kworker/u256:0:165233 blocked for more than 120 seconds. [ 4613.666297] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 4613.674809] task:kworker/u256:0 state:D stack: 0 pid:165233 ppid: 2 flags:0x00000208 [ 4613.683959] Workqueue: 0000:74:02.0_disco_q sas_revalidate_domain [libsas] [ 4613.691518] Call trace: [ 4613.694678] __switch_to+0xf8/0x17c [ 4613.698872] __schedule+0x660/0xee0 [ 4613.703063] schedule+0xac/0x240 [ 4613.706994] schedule_timeout+0x500/0x610 [ 4613.711705] __down+0x128/0x36c [ 4613.715548] down+0x240/0x2d0 [ 4613.719221] hisi_sas_internal_abort_timeout+0x1bc/0x260 [hisi_sas_main] [ 4613.726618] sas_execute_internal_abort+0x144/0x310 [libsas] [ 4613.732976] sas_execute_internal_abort_dev+0x44/0x60 [libsas] [ 4613.739504] hisi_sas_internal_task_abort_dev.isra.0+0xbc/0x1b0 [hisi_sas_main] [ 4613.747499] hisi_sas_dev_gone+0x174/0x250 [hisi_sas_main] [ 4613.753682] sas_notify_lldd_dev_gone+0xec/0x2e0 [libsas] [ 4613.759781] sas_unregister_common_dev+0x4c/0x7a0 [libsas] [ 4613.765962] sas_destruct_devices+0xb8/0x120 [libsas] [ 4613.771709] sas_do_revalidate_domain.constprop.0+0x1b8/0x31c [libsas] [ 4613.778930] sas_revalidate_domain+0x60/0xa4 [libsas] [ 4613.784716] process_one_work+0x248/0x950 [ 4613.789424] worker_thread+0x318/0x934 [ 4613.793878] kthread+0x190/0x200 [ 4613.797810] ret_from_fork+0x10/0x18 [ 4613.802121] INFO: task kworker/u256:4:316722 blocked for more than 120 seconds. [ 4613.816026] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 4613.824538] task:kworker/u256:4 state:D stack: 0 pid:316722 ppid: 2 flags:0x00000208 [ 4613.833670] Workqueue: 0000:74:02.0 hisi_sas_rst_work_handler [hisi_sas_main] [ 4613.841491] Call trace: [ 4613.844647] __switch_to+0xf8/0x17c [ 4613.848852] __schedule+0x660/0xee0 [ 4613.853052] schedule+0xac/0x240 [ 4613.856984] schedule_timeout+0x500/0x610 [ 4613.861695] __down+0x128/0x36c [ 4613.865542] down+0x240/0x2d0 [ 4613.869216] hisi_sas_controller_prereset+0x58/0x1fc [hisi_sas_main] [ 4613.876324] hisi_sas_rst_work_handler+0x40/0x8c [hisi_sas_main] [ 4613.883019] process_one_work+0x248/0x950 [ 4613.887732] worker_thread+0x318/0x934 [ 4613.892204] kthread+0x190/0x200 [ 4613.896118] ret_from_fork+0x10/0x18 [ 4613.900423] INFO: task kworker/u256:1:348985 blocked for more than 121 seconds. [ 4613.914341] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 4613.922852] task:kworker/u256:1 state:D stack: 0 pid:348985 ppid: 2 flags:0x00000208 [ 4613.931984] Workqueue: 0000:74:02.0_event_q sas_port_event_worker [libsas] [ 4613.939549] Call trace: [ 4613.942702] __switch_to+0xf8/0x17c [ 4613.946892] __schedule+0x660/0xee0 [ 4613.951083] schedule+0xac/0x240 [ 4613.955015] schedule_timeout+0x500/0x610 [ 4613.959725] wait_for_common+0x200/0x610 [ 4613.964349] wait_for_completion+0x3c/0x5c [ 4613.969146] flush_workqueue+0x198/0x790 [ 4613.973776] sas_porte_broadcast_rcvd+0x1e8/0x320 [libsas] [ 4613.979960] sas_port_event_worker+0x54/0xa0 [libsas] [ 4613.985708] process_one_work+0x248/0x950 [ 4613.990420] worker_thread+0x318/0x934 [ 4613.994868] kthread+0x190/0x200 [ 4613.998800] ret_from_fork+0x10/0x18
This is because when the device goes offline, we obtain the hisi_hba semaphore and send the ABORT_DEV command to the device. However, the internal abort timed out due to the 2 bit ECC error and triggers automatic dump. In addition, since the hisi_hba semaphore has been obtained, the dump cannot be executed and the controller cannot be reset.
Therefore, the deadlocks occur on the following circular dependencies:hisi_sas_dev_gone() -> down() -> hisi_sas_internal_task_abort_dev() -> ... -> hisi_sas_internal_abort_timeout() -> down().
The deadlock is triggered only when the timeout occurs during device goes offline. To fix this issue, use .rst_ha_timeout to distinguish the scenario where a device goes offline from other scenarios.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +10 -2
@@ -1962,9 +1962,17 @@ static bool hisi_sas_internal_abort_timeout(struct sas_task *task,struct hisi_sas_internal_abort_data *timeout = data;if (hisi_sas_debugfs_enable && hisi_hba->debugfs_itct[0 ].itct) { -down (&hisi_hba->sem); +/* +* If timeout occurs in device gone scenario, to avoid +* circular dependency like: +* hisi_sas_dev_gone() -> down() -> ... -> +* hisi_sas_internal_abort_timeout() -> down(). +*/ +if (!timeout->rst_ha_timeout) +down (&hisi_hba->sem); hisi_hba->hw->debugfs_snapshot_regs (hisi_hba); -up (&hisi_hba->sem); +if (!timeout->rst_ha_timeout) +up (&hisi_hba->sem); }if (task->task_state_flags &SAS_TASK_STATE_DONE ) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 565/713 RDMA/irdma: Remove duplicate assignment
In reply to Sasha LevinFrom: Mustafa Ismail <[email protected]>
[ Upstream commit 926e8ea4b8dac84f6d14a4b60d0653f1f2ba9431 ]
Remove the unneeded assignment of the qp_num which is already set in irdma_create_qp().
--- drivers/infiniband/hw/irdma/verbs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/irdma/verbs.c +1 -2
@@ -719,7 +719,6 @@ static int irdma_setup_kmode_qp(struct irdma_device *iwdev, info->rq_pa + (ukinfo->rq_depth *IRDMA_QP_WQE_MIN_SIZE ); ukinfo->sq_size = ukinfo->sq_depth >> ukinfo->sq_shift; ukinfo->rq_size = ukinfo->rq_depth >> ukinfo->rq_shift; - ukinfo->qp_id = iwqp->ibqp.qp_num; iwqp->max_send_wr = (ukinfo->sq_depth -IRDMA_SQ_RSVD ) >> ukinfo->sq_shift; iwqp->max_recv_wr = (ukinfo->rq_depth -IRDMA_RQ_RSVD ) >> ukinfo->rq_shift;
@@ -944,7 +943,7 @@ static int irdma_create_qp(struct ib_qp *ibqp, iwqp->host_ctx.size =IRDMA_QP_CTX_SIZE ; init_info.pd = &iwpd->sc_pd; - init_info.qp_uk_init_info.qp_id = iwqp->ibqp.qp_num; + init_info.qp_uk_init_info.qp_id = qp_num;if (!rdma_protocol_roce (&iwdev->ibdev,1 )) init_info.qp_uk_init_info.first_sq_wq =1 ; iwqp->ctx_info.qp_compl_ctx = (uintptr_t )qp;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 566/713 RDMA/srpt: Do not register event handler until srpt device is fully setup
In reply to Sasha LevinFrom: William Kucharski <[email protected]>
[ Upstream commit c21a8870c98611e8f892511825c9607f1e2cd456 ]
Upon rare occasions, KASAN reports a use-after-free Write in srpt_refresh_port().
This seems to be because an event handler is registered before the srpt device is fully setup and a race condition upon error may leave a partially setup event handler in place.
Instead, only register the event handler after srpt device initialization is complete.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +1 -2
@@ -3209,7 +3209,6 @@ static int srpt_add_one(struct ib_device *device)INIT_IB_EVENT_HANDLER (&sdev->event_handler, sdev->device, srpt_event_handler); -ib_register_event_handler (&sdev->event_handler);for (i =1 ; i <= sdev->device->phys_port_cnt; i++) { sport = &sdev->port[i -1 ];
@@ -3232,6 +3231,7 @@ static int srpt_add_one(struct ib_device *device) } } +ib_register_event_handler (&sdev->event_handler);spin_lock (&srpt_dev_lock);list_add_tail (&sdev->list, &srpt_dev_list);spin_unlock (&srpt_dev_lock);
@@ -3242,7 +3242,6 @@ static int srpt_add_one(struct ib_device *device) err_port:srpt_unregister_mad_agent (sdev, i); -ib_unregister_event_handler (&sdev->event_handler); err_cm:if (sdev->cm_id)ib_destroy_cm_id (sdev->cm_id);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 567/713 f2fs: compress: fix to guarantee persisting compressed blocks by CP
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit 8a430dd49e9cb021372b0ad91e60aeef9c6ced00 ]
If data block in compressed cluster is not persisted with metadata during checkpoint, after SPOR, the data may be corrupted, let's guarantee to write compressed page by checkpoint.
--- fs/f2fs/compress.c | 4 +++- fs/f2fs/data.c | 17 +++++++++-------- fs/f2fs/f2fs.h | 4 +++- 3 files changed, 15 insertions(+), 10 deletions(-)
fs/f2fs/compress.c +3 -1
@@ -1420,6 +1420,8 @@ void f2fs_compress_write_end_io(struct bio *bio, struct page *page)struct f2fs_sb_info *sbi = bio->bi_private;struct compress_io_ctx *cic = (struct compress_io_ctx *)page_private (page); +enum count_type type =WB_DATA_TYPE (page, +f2fs_is_compressed_page (page));int i;if (unlikely (bio->bi_status))
@@ -1427,7 +1429,7 @@ void f2fs_compress_write_end_io(struct bio *bio, struct page *page)f2fs_compress_free_page (page); -dec_page_count (sbi,F2FS_WB_DATA ); +dec_page_count (sbi, type);if (atomic_dec_return (&cic->pending_pages))return ;
fs/f2fs/data.c +9 -8
@@ -48,7 +48,7 @@ void f2fs_destroy_bioset(void)bioset_exit (&f2fs_bioset); } -static bool __is_cp_guaranteed (struct page *page) +bool f2fs_is_cp_guaranteed (struct page *page) {struct address_space *mapping = page->mapping;struct inode *inode;
@@ -65,8 +65,6 @@ static bool __is_cp_guaranteed(struct page *page) S_ISDIR(inode->i_mode))return true; -if (f2fs_is_compressed_page (page)) -return false;if ((S_ISREG (inode->i_mode) &&IS_NOQUOTA (inode)) ||page_private_gcing (page))return true;
@@ -338,7 +336,7 @@ static void f2fs_write_end_io(struct bio *bio)bio_for_each_segment_all (bvec, bio, iter_all) {struct page *page = bvec->bv_page; -enum count_type type =WB_DATA_TYPE (page); +enum count_type type =WB_DATA_TYPE (page, false);if (page_private_dummy (page)) {clear_page_private_dummy (page);
@@ -762,7 +760,7 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)wbc_account_cgroup_owner (fio->io_wbc, fio->page,PAGE_SIZE );inc_page_count (fio->sbi,is_read_io (fio->op) ? -__read_io_type (page) :WB_DATA_TYPE (fio->page)); +__read_io_type (page) :WB_DATA_TYPE (fio->page, false));if (is_read_io (bio_op (bio)))f2fs_submit_read_bio (fio->sbi, bio, fio->type);
@@ -973,7 +971,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)if (fio->io_wbc)wbc_account_cgroup_owner (fio->io_wbc, fio->page,PAGE_SIZE ); -inc_page_count (fio->sbi,WB_DATA_TYPE (page)); +inc_page_count (fio->sbi,WB_DATA_TYPE (page, false)); *fio->last_block = fio->new_blkaddr; *fio->bio = bio;
@@ -1007,6 +1005,7 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio)enum page_type btype =PAGE_TYPE_OF_BIO (fio->type);struct f2fs_bio_info *io = sbi->write_io[btype] + fio->temp;struct page *bio_page; +enum count_type type;f2fs_bug_on (sbi,is_read_io (fio->op));
@@ -1046,7 +1045,8 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio)/* set submitted = true as a return value */ fio->submitted =1 ; -inc_page_count (sbi,WB_DATA_TYPE (bio_page)); + type =WB_DATA_TYPE (bio_page, fio->compressed_page); +inc_page_count (sbi, type); if (io->bio && (!io_is_mergeable(sbi, io->bio, io, fio, io->last_block_in_bio,
@@ -1059,7 +1059,8 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio)if (F2FS_IO_ALIGNED (sbi) && (fio->type ==DATA || fio->type ==NODE ) && fio->new_blkaddr &F2FS_IO_SIZE_MASK (sbi)) { -dec_page_count (sbi,WB_DATA_TYPE (bio_page)); +dec_page_count (sbi,WB_DATA_TYPE (bio_page, + fio->compressed_page)); fio->retry =1 ; goto skip; }
fs/f2fs/f2fs.h +3 -1
@@ -1075,7 +1075,8 @@ struct f2fs_sm_info {* f2fs monitors the number of several block types such as on-writeback, * dirty dentry blocks, dirty node blocks, and dirty meta blocks. */ -#define WB_DATA_TYPE (p) (__is_cp_guaranteed(p) ? F2FS_WB_CP_DATA : F2FS_WB_DATA) +#define WB_DATA_TYPE (p, f) \ + (f || f2fs_is_cp_guaranteed(p) ? F2FS_WB_CP_DATA : F2FS_WB_DATA)enum count_type {F2FS_DIRTY_DENTS ,F2FS_DIRTY_DATA ,
@@ -3797,6 +3798,7 @@ void f2fs_init_ckpt_req_control(struct f2fs_sb_info *sbi);*/ int __init f2fs_init_bioset (void );void f2fs_destroy_bioset (void ); +bool f2fs_is_cp_guaranteed (struct page *page);int f2fs_init_bio_entry_cache (void );void f2fs_destroy_bio_entry_cache (void ); void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, struct bio *bio,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 568/713 f2fs: compress: fix to cover normal cluster write with cp_rwsem
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit fd244524c2cf07b5f4c3fe8abd6a99225c76544b ]
When we overwrite compressed cluster w/ normal cluster, we should not unlock cp_rwsem during f2fs_write_raw_pages(), otherwise data will be corrupted if partial blocks were persisted before CP & SPOR, due to cluster metadata wasn't updated atomically.
--- fs/f2fs/compress.c | 27 ++++++++++++++++++--------- fs/f2fs/data.c | 3 ++- 2 files changed, 20 insertions(+), 10 deletions(-)
fs/f2fs/compress.c +18 -9
@@ -1445,12 +1445,14 @@ void f2fs_compress_write_end_io(struct bio *bio, struct page *page) }static int f2fs_write_raw_pages (struct compress_ctx *cc, -int *submitted, +int *submitted_p,struct writeback_control *wbc,enum iostat_type io_type) {struct address_space *mapping = cc->inode->i_mapping; -int _submitted, compr_blocks, ret, i; +struct f2fs_sb_info *sbi =F2FS_M_SB (mapping); +int submitted, compr_blocks, i; +int ret =0 ; compr_blocks =f2fs_compressed_blocks (cc);
@@ -1465,6 +1467,10 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc,if (compr_blocks <0 )return compr_blocks; +/* overwrite compressed cluster w/ normal cluster */ +if (compr_blocks >0 ) +f2fs_lock_op (sbi); +for (i =0 ; i < cc->cluster_size; i++) {if (!cc->rpages[i])continue ;
@@ -1489,7 +1495,7 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc,if (!clear_page_dirty_for_io (cc->rpages[i])) goto continue_unlock; - ret =f2fs_write_single_data_page (cc->rpages[i], &_submitted, + ret =f2fs_write_single_data_page (cc->rpages[i], &submitted,NULL ,NULL , wbc, io_type, compr_blocks, false);if (ret) {
@@ -1497,26 +1503,29 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc,unlock_page (cc->rpages[i]); ret =0 ; }else if (ret == -EAGAIN ) { + ret =0 ;/* * for quota file, just redirty left pages to * avoid deadlock caused by cluster update race * from foreground operation. */ if (IS_NOQUOTA (cc->inode)) -return 0 ; - ret =0 ; + goto out;f2fs_io_schedule_timeout (DEFAULT_IO_TIMEOUT ); goto retry_write; } -return ret; + goto out; } - *submitted += _submitted; + *submitted_p += submitted; } -f2fs_balance_fs (F2FS_M_SB (mapping), true); +out: +if (compr_blocks >0 ) +f2fs_unlock_op (sbi); -return 0 ; +f2fs_balance_fs (sbi, true); +return ret; } int f2fs_write_multi_pages(struct compress_ctx *cc,
fs/f2fs/data.c +2 -1
@@ -2851,7 +2851,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, .encrypted_page = NULL, .submitted = 0, .compr_blocks = compr_blocks, - .need_lock = LOCK_RETRY, + .need_lock = compr_blocks ? LOCK_DONE : LOCK_RETRY, .post_read = f2fs_post_read_required(inode) ? 1 : 0, .io_type = io_type, .io_wbc = wbc,
@@ -2935,6 +2935,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,if (err == -EAGAIN ) { err =f2fs_do_write_data_page (&fio);if (err == -EAGAIN ) { +f2fs_bug_on (sbi, compr_blocks); fio.need_lock =LOCK_REQ ; err =f2fs_do_write_data_page (&fio); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 569/713 f2fs: compress: fix to check unreleased compressed cluster
In reply to Sasha LevinFrom: Sheng Yong <[email protected]>
[ Upstream commit eb8fbaa53374e0a2d4381190abfe708481517bbb ]
Compressed cluster may not be released due to we can fail in release_compress_blocks(), fix to handle reserved compressed cluster correctly in reserve_compress_blocks().
--- fs/f2fs/file.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
fs/f2fs/file.c +12 -1
@@ -3631,7 +3631,13 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count) goto next; } -if (__is_valid_data_blkaddr (blkaddr)) { +/* +* compressed cluster was not released due to it +* fails in release_compress_blocks(), so NEW_ADDR +* is a possible case. +*/ +if (blkaddr ==NEW_ADDR || +__is_valid_data_blkaddr (blkaddr)) { compr_blocks++;continue ; }
@@ -3641,6 +3647,11 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count) } reserved = cluster_size - compr_blocks; + +/* for the case all blocks in cluster were reserved */ +if (reserved ==1 ) + goto next; + ret =inc_valid_block_count (sbi, dn->inode, &reserved);if (ret)return ret;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 570/713 f2fs: delete obsolete FI_FIRST_BLOCK_WRITTEN
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit a53936361330e4c55c0654605178281387d9c761 ]
Commit 3c6c2bebef79 ("f2fs: avoid punch_hole overhead when releasing volatile data") introduced FI_FIRST_BLOCK_WRITTEN as below reason:
This patch is to avoid some punch_hole overhead when releasing volatile data. If volatile data was not written yet, we just can make the first page as zero.
After commit 7bc155fec5b3 ("f2fs: kill volatile write support"), we won't support volatile write, but it missed to remove obsolete FI_FIRST_BLOCK_WRITTEN, delete it in this patch.
Stable-dep-of: 54607494875e ("f2fs: compress: fix to avoid inconsistence bewteen i_blocks and dnode")
--- fs/f2fs/compress.c | 2 -- fs/f2fs/data.c | 2 -- fs/f2fs/f2fs.h | 6 ------ fs/f2fs/file.c | 3 --- fs/f2fs/gc.c | 2 -- fs/f2fs/inode.c | 25 ------------------------- 6 files changed, 40 deletions(-)
fs/f2fs/compress.c +0 -2
@@ -1371,8 +1371,6 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,add_compr_block_stat (inode, cc->valid_nr_cpages);set_inode_flag (cc->inode,FI_APPEND_WRITE ); -if (cc->cluster_idx ==0 ) -set_inode_flag (inode,FI_FIRST_BLOCK_WRITTEN );f2fs_put_dnode (&dn);if (quota_inode)
fs/f2fs/data.c +0 -2
@@ -2812,8 +2812,6 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio)f2fs_outplace_write_data (&dn, fio);trace_f2fs_do_write_data_page (page,OPU );set_inode_flag (inode,FI_APPEND_WRITE ); -if (page->index ==0 ) -set_inode_flag (inode,FI_FIRST_BLOCK_WRITTEN ); out_writepage:f2fs_put_dnode (&dn); out:
fs/f2fs/f2fs.h +0 -6
@@ -774,7 +774,6 @@ enum {FI_UPDATE_WRITE ,/* inode has in-place-update data */ FI_NEED_IPU ,/* used for ipu per file */ FI_ATOMIC_FILE ,/* indicate atomic file */ -FI_FIRST_BLOCK_WRITTEN ,/* indicate #0 data block was written */ FI_DROP_CACHE ,/* drop dirty page cache */ FI_DATA_EXIST ,/* indicate data exists */ FI_INLINE_DOTS, /* indicate inline dot dentries */
@@ -3273,11 +3272,6 @@ static inline bool f2fs_is_cow_file(struct inode *inode)return is_inode_flag_set (inode,FI_COW_FILE ); } -static inline bool f2fs_is_first_block_written (struct inode *inode) -{ -return is_inode_flag_set (inode,FI_FIRST_BLOCK_WRITTEN ); -} -static inline bool f2fs_is_drop_cache (struct inode *inode) {return is_inode_flag_set (inode,FI_DROP_CACHE );
fs/f2fs/file.c +0 -3
@@ -599,9 +599,6 @@ void f2fs_truncate_data_blocks_range(struct dnode_of_data *dn, int count) valid_blocks++; } -if (dn->ofs_in_node ==0 &&IS_INODE (dn->node_page)) -clear_inode_flag (dn->inode,FI_FIRST_BLOCK_WRITTEN ); -f2fs_invalidate_blocks (sbi, blkaddr);if (!released || blkaddr !=COMPRESS_ADDR )
fs/f2fs/gc.c +0 -2
@@ -1405,8 +1405,6 @@ static int move_data_block(struct inode *inode, block_t bidx,f2fs_update_data_blkaddr (&dn, newaddr);set_inode_flag (inode,FI_APPEND_WRITE ); -if (page->index ==0 ) -set_inode_flag (inode,FI_FIRST_BLOCK_WRITTEN ); put_page_out:f2fs_put_page (fio.encrypted_page,1 ); recover_block:
fs/f2fs/inode.c +0 -25
@@ -76,20 +76,6 @@ static void __get_inode_rdev(struct inode *inode, struct f2fs_inode *ri) } } -static int __written_first_block (struct f2fs_sb_info *sbi, -struct f2fs_inode *ri) -{ -block_t addr =le32_to_cpu (ri->i_addr[offset_in_addr (ri)]); - -if (!__is_valid_data_blkaddr (addr)) -return 1 ; -if (!f2fs_is_valid_blkaddr (sbi, addr,DATA_GENERIC_ENHANCE )) { -f2fs_handle_error (sbi,ERROR_INVALID_BLKADDR ); -return -EFSCORRUPTED ; - } -return 0 ; -} -static void __set_inode_rdev (struct inode *inode,struct f2fs_inode *ri) {int extra_size =get_extra_isize (inode);
@@ -398,7 +384,6 @@ static int do_read_inode(struct inode *inode)struct page *node_page;struct f2fs_inode *ri;projid_t i_projid; -int err;/* Check if ino is within scope */ if (f2fs_check_nid_range (sbi, inode->i_ino))
@@ -480,16 +465,6 @@ static int do_read_inode(struct inode *inode)/* get rdev by using inline_info */ __get_inode_rdev (inode, ri); -if (S_ISREG (inode->i_mode)) { - err =__written_first_block (sbi, ri); -if (err <0 ) { -f2fs_put_page (node_page,1 ); -return err; - } -if (!err) -set_inode_flag (inode,FI_FIRST_BLOCK_WRITTEN ); - } -if (!f2fs_need_inode_block_update (sbi, inode->i_ino)) fi->last_disk_size = inode->i_size;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 571/713 f2fs: delete obsolete FI_DROP_CACHE
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit bb6e1c8fa5b9b95bbb8e39b6105f8f6550e070fc ]
FI_DROP_CACHE was introduced in commit 1e84371ffeef ("f2fs: change atomic and volatile write policies") for volatile write feature, after commit 7bc155fec5b3 ("f2fs: kill volatile write support"), we won't support volatile write, let's delete related codes.
Stable-dep-of: 54607494875e ("f2fs: compress: fix to avoid inconsistence bewteen i_blocks and dnode")
--- fs/f2fs/data.c | 3 --- fs/f2fs/f2fs.h | 6 ------ 2 files changed, 9 deletions(-)
fs/f2fs/data.c +0 -3
@@ -2894,9 +2894,6 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,zero_user_segment (page, offset,PAGE_SIZE ); write: -if (f2fs_is_drop_cache (inode)) - goto out; -/* Dentry/quota blocks are controlled by checkpoint */ if (S_ISDIR (inode->i_mode) || quota_inode) {/*
fs/f2fs/f2fs.h +0 -6
@@ -774,7 +774,6 @@ enum {FI_UPDATE_WRITE ,/* inode has in-place-update data */ FI_NEED_IPU ,/* used for ipu per file */ FI_ATOMIC_FILE ,/* indicate atomic file */ -FI_DROP_CACHE ,/* drop dirty page cache */ FI_DATA_EXIST ,/* indicate data exists */ FI_INLINE_DOTS ,/* indicate inline dot dentries */ FI_SKIP_WRITES, /* should skip data page writeback */
@@ -3272,11 +3271,6 @@ static inline bool f2fs_is_cow_file(struct inode *inode)return is_inode_flag_set (inode,FI_COW_FILE ); } -static inline bool f2fs_is_drop_cache (struct inode *inode) -{ -return is_inode_flag_set (inode,FI_DROP_CACHE ); -} -static inline void *inline_data_addr (struct inode *inode,struct page *page) {struct f2fs_inode *ri =F2FS_INODE (page);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 572/713 f2fs: introduce get_dnode_addr() to clean up codes
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit 2020cd48e41cb8470bb1ca0835033d13d3178425 ]
Just cleanup, no logic changes.
Stable-dep-of: 54607494875e ("f2fs: compress: fix to avoid inconsistence bewteen i_blocks and dnode")
--- fs/f2fs/data.c | 11 ++--------- fs/f2fs/f2fs.h | 18 +++++++++++++++--- fs/f2fs/file.c | 8 +------- fs/f2fs/inode.c | 32 ++++++++++++++------------------ 4 files changed, 32 insertions(+), 37 deletions(-)
fs/f2fs/data.c +2 -9
@@ -1182,16 +1182,9 @@ static int f2fs_submit_page_read(struct inode *inode, struct page *page,static void __set_data_blkaddr (struct dnode_of_data *dn) { -struct f2fs_node *rn =F2FS_NODE (dn->node_page); -__le32 *addr_array; -int base =0 ; +__le32 *addr =get_dnode_addr (dn->inode, dn->node_page); -if (IS_INODE (dn->node_page) &&f2fs_has_extra_attr (dn->inode)) - base =get_extra_isize (dn->inode); - -/* Get physical address of data block */ - addr_array =blkaddr_in_node (rn); - addr_array[base + dn->ofs_in_node] =cpu_to_le32 (dn->data_blkaddr); + addr[dn->ofs_in_node] =cpu_to_le32 (dn->data_blkaddr); }/*
fs/f2fs/f2fs.h +15 -3
@@ -3271,12 +3271,13 @@ static inline bool f2fs_is_cow_file(struct inode *inode)return is_inode_flag_set (inode,FI_COW_FILE ); } +static inline __le32 *get_dnode_addr (struct inode *inode, +struct page *node_page);static inline void *inline_data_addr (struct inode *inode,struct page *page) { -struct f2fs_inode *ri =F2FS_INODE (page); -int extra_size =get_extra_isize (inode); +__le32 *addr =get_dnode_addr (inode, page); -return (void *)&(ri->i_addr[extra_size +DEF_INLINE_RESERVED_SIZE ]); +return (void *)(addr +DEF_INLINE_RESERVED_SIZE ); }static inline int f2fs_has_inline_dentry (struct inode *inode)
@@ -3421,6 +3422,17 @@ static inline int get_inline_xattr_addrs(struct inode *inode)return F2FS_I (inode)->i_inline_xattr_size; } +static inline __le32 *get_dnode_addr (struct inode *inode, +struct page *node_page) +{ +int base =0 ; + +if (IS_INODE (node_page) &&f2fs_has_extra_attr (inode)) + base =get_extra_isize (inode); + +return blkaddr_in_node (F2FS_NODE (node_page)) + base; +} +#define f2fs_get_inode_mode (i) \ ((is_inode_flag_set(i, FI_ACL_MODE)) ? \ (F2FS_I(i)->i_acl_mode) : ((i)->i_mode))
fs/f2fs/file.c +1 -7
@@ -557,20 +557,14 @@ static int f2fs_file_open(struct inode *inode, struct file *filp)void f2fs_truncate_data_blocks_range (struct dnode_of_data *dn,int count) {struct f2fs_sb_info *sbi =F2FS_I_SB (dn->inode); -struct f2fs_node *raw_node;int nr_free =0 , ofs = dn->ofs_in_node, len = count;__le32 *addr; -int base =0 ;bool compressed_cluster = false;int cluster_index =0 , valid_blocks =0 ;int cluster_size =F2FS_I (dn->inode)->i_cluster_size;bool released = !atomic_read (&F2FS_I (dn->inode)->i_compr_blocks); -if (IS_INODE (dn->node_page) &&f2fs_has_extra_attr (dn->inode)) - base =get_extra_isize (dn->inode); - - raw_node =F2FS_NODE (dn->node_page); - addr =blkaddr_in_node (raw_node) + base + ofs; + addr =get_dnode_addr (dn->inode, dn->node_page) + ofs;/* Assumption: truncation starts with cluster */ for (; count >0 ; count--, addr++, dn->ofs_in_node++, cluster_index++) {
fs/f2fs/inode.c +14 -18
@@ -61,35 +61,31 @@ void f2fs_set_inode_flags(struct inode *inode) S_ENCRYPTED|S_VERITY|S_CASEFOLD); } -static void __get_inode_rdev (struct inode *inode,struct f2fs_inode *ri) +static void __get_inode_rdev (struct inode *inode,struct page *node_page) { -int extra_size =get_extra_isize (inode); +__le32 *addr =get_dnode_addr (inode, node_page);if (S_ISCHR (inode->i_mode) ||S_ISBLK (inode->i_mode) ||S_ISFIFO (inode->i_mode) ||S_ISSOCK (inode->i_mode)) { -if (ri->i_addr[extra_size]) - inode->i_rdev =old_decode_dev ( -le32_to_cpu (ri->i_addr[extra_size])); +if (addr[0 ]) + inode->i_rdev =old_decode_dev (le32_to_cpu (addr[0 ]));else - inode->i_rdev =new_decode_dev ( -le32_to_cpu (ri->i_addr[extra_size +1 ])); + inode->i_rdev =new_decode_dev (le32_to_cpu (addr[1 ])); } } -static void __set_inode_rdev (struct inode *inode,struct f2fs_inode *ri) +static void __set_inode_rdev (struct inode *inode,struct page *node_page) { -int extra_size =get_extra_isize (inode); +__le32 *addr =get_dnode_addr (inode, node_page);if (S_ISCHR (inode->i_mode) ||S_ISBLK (inode->i_mode)) {if (old_valid_dev (inode->i_rdev)) { - ri->i_addr[extra_size] = -cpu_to_le32 (old_encode_dev (inode->i_rdev)); - ri->i_addr[extra_size +1 ] =0 ; + addr[0 ] =cpu_to_le32 (old_encode_dev (inode->i_rdev)); + addr[1 ] =0 ; }else { - ri->i_addr[extra_size] =0 ; - ri->i_addr[extra_size +1 ] = -cpu_to_le32 (new_encode_dev (inode->i_rdev)); - ri->i_addr[extra_size +2 ] =0 ; + addr[0 ] =0 ; + addr[1 ] =cpu_to_le32 (new_encode_dev (inode->i_rdev)); + addr[2 ] =0 ; } } }
@@ -463,7 +459,7 @@ static int do_read_inode(struct inode *inode) }/* get rdev by using inline_info */ -__get_inode_rdev (inode, ri); +__get_inode_rdev (inode, node_page);if (!f2fs_need_inode_block_update (sbi, inode->i_ino)) fi->last_disk_size = inode->i_size;
@@ -736,7 +732,7 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page) } } -__set_inode_rdev (inode, ri); +__set_inode_rdev (inode, node_page);/* deleted inode */ if (inode->i_nlink ==0 )
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 573/713 f2fs: update blkaddr in __set_data_blkaddr() for cleanup
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit 59d0d4c3eae0f3dd8886ed59f89f21fa09e324f5 ]
This patch allows caller to pass blkaddr to f2fs_set_data_blkaddr() and let __set_data_blkaddr() inside f2fs_set_data_blkaddr() to update dn->data_blkaddr w/ last value of blkaddr.
Just cleanup, no logic changes.
Stable-dep-of: 54607494875e ("f2fs: compress: fix to avoid inconsistence bewteen i_blocks and dnode")
--- fs/f2fs/data.c | 13 ++++++------- fs/f2fs/f2fs.h | 2 +- fs/f2fs/file.c | 12 ++++-------- 3 files changed, 11 insertions(+), 16 deletions(-)
fs/f2fs/data.c +6 -7
@@ -1180,10 +1180,11 @@ static int f2fs_submit_page_read(struct inode *inode, struct page *page,return 0 ; } -static void __set_data_blkaddr (struct dnode_of_data *dn) +static void __set_data_blkaddr (struct dnode_of_data *dn,block_t blkaddr) {__le32 *addr =get_dnode_addr (dn->inode, dn->node_page); + dn->data_blkaddr = blkaddr; addr[dn->ofs_in_node] =cpu_to_le32 (dn->data_blkaddr); }
@@ -1193,18 +1194,17 @@ static void __set_data_blkaddr(struct dnode_of_data *dn)* ->node_page * update block addresses in the node page */ -void f2fs_set_data_blkaddr (struct dnode_of_data *dn) +void f2fs_set_data_blkaddr (struct dnode_of_data *dn,block_t blkaddr) {f2fs_wait_on_page_writeback (dn->node_page,NODE , true, true); -__set_data_blkaddr (dn); +__set_data_blkaddr (dn, blkaddr);if (set_page_dirty (dn->node_page)) dn->node_changed = true; }void f2fs_update_data_blkaddr (struct dnode_of_data *dn,block_t blkaddr) { - dn->data_blkaddr = blkaddr; -f2fs_set_data_blkaddr (dn); +f2fs_set_data_blkaddr (dn, blkaddr);f2fs_update_read_extent_cache (dn); }
@@ -1231,8 +1231,7 @@ int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count)block_t blkaddr =f2fs_data_blkaddr (dn);if (blkaddr ==NULL_ADDR ) { - dn->data_blkaddr =NEW_ADDR ; -__set_data_blkaddr (dn); +__set_data_blkaddr (dn,NEW_ADDR ); count--; } }
fs/f2fs/f2fs.h +1 -1
@@ -3817,7 +3817,7 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio);struct block_device *f2fs_target_device (struct f2fs_sb_info *sbi,block_t blk_addr,sector_t *sector);int f2fs_target_device_index (struct f2fs_sb_info *sbi,block_t blkaddr); -void f2fs_set_data_blkaddr (struct dnode_of_data *dn); +void f2fs_set_data_blkaddr (struct dnode_of_data *dn,block_t blkaddr);void f2fs_update_data_blkaddr (struct dnode_of_data *dn,block_t blkaddr);int f2fs_reserve_new_blocks (struct dnode_of_data *dn,blkcnt_t count);int f2fs_reserve_new_block (struct dnode_of_data *dn);
fs/f2fs/file.c +4 -8
@@ -582,8 +582,7 @@ void f2fs_truncate_data_blocks_range(struct dnode_of_data *dn, int count)if (blkaddr ==NULL_ADDR )continue ; - dn->data_blkaddr =NULL_ADDR ; -f2fs_set_data_blkaddr (dn); +f2fs_set_data_blkaddr (dn,NULL_ADDR ); if (__is_valid_data_blkaddr(blkaddr)) { if (!f2fs_is_valid_blkaddr(sbi, blkaddr,
@@ -1479,8 +1478,7 @@ static int f2fs_do_zero_range(struct dnode_of_data *dn, pgoff_t start, }f2fs_invalidate_blocks (sbi, dn->data_blkaddr); - dn->data_blkaddr =NEW_ADDR ; -f2fs_set_data_blkaddr (dn); +f2fs_set_data_blkaddr (dn,NEW_ADDR ); }f2fs_update_read_extent_cache_range (dn, start,0 , index - start);
@@ -3460,8 +3458,7 @@ static int release_compress_blocks(struct dnode_of_data *dn, pgoff_t count)if (blkaddr !=NEW_ADDR )continue ; - dn->data_blkaddr =NULL_ADDR ; -f2fs_set_data_blkaddr (dn); +f2fs_set_data_blkaddr (dn,NULL_ADDR ); }f2fs_i_compr_blocks_update (dn->inode, compr_blocks, false);
@@ -3633,8 +3630,7 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count)continue ; } - dn->data_blkaddr =NEW_ADDR ; -f2fs_set_data_blkaddr (dn); +f2fs_set_data_blkaddr (dn,NEW_ADDR ); } reserved = cluster_size - compr_blocks;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 574/713 f2fs: compress: fix to avoid inconsistence bewteen i_blocks and dnode
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit 54607494875edd636aff3c21ace3ad9a7da758a9 ]
In reserve_compress_blocks(), we update blkaddrs of dnode in prior to inc_valid_block_count(), it may cause inconsistent status bewteen i_blocks and blkaddrs once inc_valid_block_count() fails.
To fix this issue, it needs to reverse their invoking order.
--- fs/f2fs/data.c | 5 +++-- fs/f2fs/f2fs.h | 7 ++++++- fs/f2fs/file.c | 26 ++++++++++++++------------ fs/f2fs/segment.c | 2 +- 4 files changed, 24 insertions(+), 16 deletions(-)
fs/f2fs/data.c +3 -2
@@ -1219,7 +1219,8 @@ int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count)if (unlikely (is_inode_flag_set (dn->inode,FI_NO_ALLOC )))return -EPERM ; -if (unlikely ((err =inc_valid_block_count (sbi, dn->inode, &count)))) + err =inc_valid_block_count (sbi, dn->inode, &count, true); +if (unlikely (err))return err; trace_f2fs_reserve_new_blocks(dn->inode, dn->nid,
@@ -1476,7 +1477,7 @@ static int __allocate_data_block(struct dnode_of_data *dn, int seg_type) dn->data_blkaddr =f2fs_data_blkaddr (dn);if (dn->data_blkaddr ==NULL_ADDR ) { - err =inc_valid_block_count (sbi, dn->inode, &count); + err =inc_valid_block_count (sbi, dn->inode, &count, true);if (unlikely (err))return err; }
fs/f2fs/f2fs.h +6 -1
@@ -2245,7 +2245,7 @@ static inline bool __allow_reserved_blocks(struct f2fs_sb_info *sbi,static inline void f2fs_i_blocks_write (struct inode *,block_t ,bool ,bool );static inline int inc_valid_block_count (struct f2fs_sb_info *sbi, -struct inode *inode,blkcnt_t *count) +struct inode *inode,blkcnt_t *count,bool partial) {blkcnt_t diff =0 , release =0 ;block_t avail_user_block_count;
@@ -2285,6 +2285,11 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi, avail_user_block_count =0 ; }if (unlikely (sbi->total_valid_block_count > avail_user_block_count)) { +if (!partial) { +spin_unlock (&sbi->stat_lock); + goto enospc; + } + diff = sbi->total_valid_block_count - avail_user_block_count;if (diff > *count) diff = *count;
fs/f2fs/file.c +14 -12
@@ -3609,14 +3609,16 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count)blkcnt_t reserved;int ret; -for (i =0 ; i < cluster_size; i++, dn->ofs_in_node++) { - blkaddr =f2fs_data_blkaddr (dn); +for (i =0 ; i < cluster_size; i++) { + blkaddr =data_blkaddr (dn->inode, dn->node_page, + dn->ofs_in_node + i);if (i ==0 ) { -if (blkaddr ==COMPRESS_ADDR ) -continue ; - dn->ofs_in_node += cluster_size; - goto next; +if (blkaddr !=COMPRESS_ADDR ) { + dn->ofs_in_node += cluster_size; + goto next; + } +continue ; }/*
@@ -3629,8 +3631,6 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count) compr_blocks++;continue ; } - -f2fs_set_data_blkaddr (dn,NEW_ADDR ); } reserved = cluster_size - compr_blocks;
@@ -3639,12 +3639,14 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count)if (reserved ==1 ) goto next; - ret =inc_valid_block_count (sbi, dn->inode, &reserved); -if (ret) + ret =inc_valid_block_count (sbi, dn->inode, &reserved, false); +if (unlikely (ret))return ret; -if (reserved != cluster_size - compr_blocks) -return -ENOSPC ; +for (i =0 ; i < cluster_size; i++, dn->ofs_in_node++) { +if (f2fs_data_blkaddr (dn) ==NULL_ADDR ) +f2fs_set_data_blkaddr (dn,NEW_ADDR ); + }f2fs_i_compr_blocks_update (dn->inode, compr_blocks, true);
fs/f2fs/segment.c +1 -1
@@ -248,7 +248,7 @@ static int __replace_atomic_write_block(struct inode *inode, pgoff_t index, }else {blkcnt_t count =1 ; - err =inc_valid_block_count (sbi, inode, &count); + err =inc_valid_block_count (sbi, inode, &count, true);if (err) {f2fs_put_dnode (&dn);return err;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 575/713 f2fs: fix to remove unnecessary f2fs_bug_on() to avoid panic
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit b896e302f79678451a94769ddd9e52e954c64fbb ]
verify_blkaddr() will trigger panic once we inject fault into f2fs_is_valid_blkaddr(), fix to remove this unnecessary f2fs_bug_on().
--- fs/f2fs/f2fs.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/f2fs/f2fs.h +1 -3
@@ -3463,11 +3463,9 @@ bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,static inline void verify_blkaddr (struct f2fs_sb_info *sbi,block_t blkaddr,int type) { -if (!f2fs_is_valid_blkaddr (sbi, blkaddr, type)) { +if (!f2fs_is_valid_blkaddr (sbi, blkaddr, type))f2fs_err (sbi,"invalid blkaddr: %u, type: %d, run fsck to fix." , blkaddr, type); -f2fs_bug_on (sbi,1 ); - } }static inline bool __is_valid_data_blkaddr (block_t blkaddr)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 576/713 f2fs: zone: fix to wait completion of last bio in zone correctly
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit 536af8211586af09c5bea1c15ad28ddec5f66a97 ]
It needs to check last zone_pending_bio and wait IO completion before traverse next fio in io->io_list, otherwise, bio in next zone may be submitted before all IO completion in current zone.
--- fs/f2fs/data.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/data.c +1 -2
@@ -1010,7 +1010,7 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio)f2fs_bug_on (sbi,is_read_io (fio->op));f2fs_down_write (&io->io_rwsem); - +next:#ifdef CONFIG_BLK_DEV_ZONED if (f2fs_sb_has_blkzoned (sbi) && btype <META && io->zone_pending_bio) {wait_for_completion_io (&io->zone_wait);
@@ -1020,7 +1020,6 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio) }#endif -next:if (fio->in_list) {spin_lock (&io->io_lock);if (list_empty (&io->io_list)) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 577/713 f2fs: fix NULL pointer dereference in f2fs_submit_page_write()
In reply to Sasha LevinFrom: Wenjie Qi <[email protected]>
[ Upstream commit c2034ef6192a65a986a45c2aa2ed05824fdc0e9f ]
BUG: kernel NULL pointer dereference, address: 0000000000000014 RIP: 0010:f2fs_submit_page_write+0x6cf/0x780 [f2fs] Call Trace: <TASK> ? show_regs+0x6e/0x80 ? __die+0x29/0x70 ? page_fault_oops+0x154/0x4a0 ? prb_read_valid+0x20/0x30 ? __irq_work_queue_local+0x39/0xd0 ? irq_work_queue+0x36/0x70 ? do_user_addr_fault+0x314/0x6c0 ? exc_page_fault+0x7d/0x190 ? asm_exc_page_fault+0x2b/0x30 ? f2fs_submit_page_write+0x6cf/0x780 [f2fs] ? f2fs_submit_page_write+0x736/0x780 [f2fs] do_write_page+0x50/0x170 [f2fs] f2fs_outplace_write_data+0x61/0xb0 [f2fs] f2fs_do_write_data_page+0x3f8/0x660 [f2fs] f2fs_write_single_data_page+0x5bb/0x7a0 [f2fs] f2fs_write_cache_pages+0x3da/0xbe0 [f2fs]
...
It is possible that other threads have added this fio to io->bio and submitted the io->bio before entering f2fs_submit_page_write(). At this point io->bio = NULL.
If is_end_zone_blkaddr(sbi, fio->new_blkaddr) of this fio is true, then an NULL pointer dereference error occurs at bio_get(io->bio). The original code for determining zone end was after "out:", which would have missed some fio who is zone end. I've moved
this code before "skip:" to make sure it's done for each fio.
--- fs/f2fs/data.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/f2fs/data.c +4 -4
@@ -1080,10 +1080,6 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio) io->last_block_in_bio = fio->new_blkaddr;trace_f2fs_submit_page_write (fio->page, fio); -skip: -if (fio->in_list) - goto next; -out:#ifdef CONFIG_BLK_DEV_ZONED if (f2fs_sb_has_blkzoned (sbi) && btype <META &&is_end_zone_blkaddr (sbi, fio->new_blkaddr)) {
@@ -1096,6 +1092,10 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio) __submit_merged_bio(io); }#endif +skip: +if (fio->in_list) + goto next; +out:if (is_sbi_flag_set (sbi,SBI_IS_SHUTDOWN ) || !f2fs_is_checkpoint_ready (sbi))__submit_merged_bio (io);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 578/713 f2fs: compress: fix to cover f2fs_disable_compressed_file() w/ i_sem
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit 2f9420d3a94aeebd92db88f00f4f2f1a3bd3f6cf ]
- f2fs_disable_compressed_file
- check inode_has_data
- f2fs_file_mmap
- mkwrite
- f2fs_get_block_locked : update metadata in compressed inode's disk layout
- fi->i_flags &= ~F2FS_COMPR_FL
- clear_inode_flag(inode, FI_COMPRESSED_FILE);
we should use i_sem lock to prevent above race case.
--- fs/f2fs/f2fs.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
fs/f2fs/f2fs.h +11 -2
@@ -4399,15 +4399,24 @@ static inline bool f2fs_disable_compressed_file(struct inode *inode) {struct f2fs_inode_info *fi =F2FS_I (inode); -if (!f2fs_compressed_file (inode)) +f2fs_down_write (&F2FS_I (inode)->i_sem); + +if (!f2fs_compressed_file (inode)) { +f2fs_up_write (&F2FS_I (inode)->i_sem);return true; -if (S_ISREG (inode->i_mode) &&F2FS_HAS_BLOCKS (inode)) + } +if (f2fs_is_mmap_file (inode) || + (S_ISREG (inode->i_mode) &&F2FS_HAS_BLOCKS (inode))) { +f2fs_up_write (&F2FS_I (inode)->i_sem);return false; + } fi->i_flags &= ~F2FS_COMPR_FL ;stat_dec_compr_inode (inode);clear_inode_flag (inode,FI_COMPRESSED_FILE );f2fs_mark_inode_dirty_sync (inode, true); + +f2fs_up_write (&F2FS_I (inode)->i_sem);return true; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 579/713 f2fs: fix to avoid potential panic during recovery
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit 21ec68234826b1b54ab980a8df6e33c74cfbee58 ]
During recovery, if FAULT_BLOCK is on, it is possible that f2fs_reserve_new_block() will return -ENOSPC during recovery, then it may trigger panic.
Also, if fault injection rate is 1 and only FAULT_BLOCK fault type is on, it may encounter deadloop in loop of block reservation.
Let's change as below to fix these issues:
- remove bug_on() to avoid panic.
- limit the loop count of block reservation to avoid potential deadloop.
--- fs/f2fs/f2fs.h | 5 +++++ fs/f2fs/recovery.c | 33 ++++++++++++++++----------------- 2 files changed, 21 insertions(+), 17 deletions(-)
fs/f2fs/f2fs.h +5 -0
@@ -75,6 +75,11 @@ struct f2fs_fault_info {extern const char *f2fs_fault_name[FAULT_MAX ];#define IS_FAULT_SET (fi, type) ((fi)->inject_type & BIT(type)) + +/* maximum retry count for injected failure */ +#define DEFAULT_FAILURE_RETRY_COUNT 8 +#else +#define DEFAULT_FAILURE_RETRY_COUNT 1#endif /*
fs/f2fs/recovery.c +16 -17
@@ -611,6 +611,19 @@ static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi,return 0 ; } +static int f2fs_reserve_new_block_retry (struct dnode_of_data *dn) +{ +int i, err =0 ; + +for (i =DEFAULT_FAILURE_RETRY_COUNT ; i >0 ; i--) { + err =f2fs_reserve_new_block (dn); +if (!err) +break ; + } + +return err; +} +static int do_recover_data (struct f2fs_sb_info *sbi,struct inode *inode,struct page *page) {
@@ -712,14 +725,8 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,*/ if (dest ==NEW_ADDR ) {f2fs_truncate_data_blocks_range (&dn,1 ); -do { - err =f2fs_reserve_new_block (&dn); -if (err == -ENOSPC ) { -f2fs_bug_on (sbi,1 ); -break ; - } - }while (err && -IS_ENABLED (CONFIG_F2FS_FAULT_INJECTION )); + + err =f2fs_reserve_new_block_retry (&dn);if (err) goto err;continue ;
@@ -727,16 +734,8 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,/* dest is valid block, try to recover from src to dest */ if (f2fs_is_valid_blkaddr (sbi, dest,META_POR )) { -if (src ==NULL_ADDR ) { -do { - err =f2fs_reserve_new_block (&dn); -if (err == -ENOSPC ) { -f2fs_bug_on (sbi,1 ); -break ; - } - }while (err && -IS_ENABLED (CONFIG_F2FS_FAULT_INJECTION )); + err =f2fs_reserve_new_block_retry (&dn);if (err) goto err; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 580/713 scsi: csiostor: Avoid function pointer casts
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 9f3dbcb5632d6876226031d552ef6163bb3ad215 ]
csiostor uses function pointer casts to keep the csio_ln_ev state machine hidden, but this causes warnings about control flow integrity (KCFI) violations in clang-16 and higher:
drivers/scsi/csiostor/csio_lnode.c:1098:33: error: cast from 'void (*)(struct csio_lnode *, enum csio_ln_ev)' to 'csio_sm_state_t' (aka 'void (*)(void *, unsigned int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
1098 | return (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_ready));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/csiostor/csio_lnode.c:1369:29: error: cast from 'void (*)(struct csio_lnode *, enum csio_ln_ev)' to 'csio_sm_state_t' (aka 'void (*)(void *, unsigned int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
1369 | if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_uninit)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/csiostor/csio_lnode.c:1373:29: error: cast from 'void (*)(struct csio_lnode *, enum csio_ln_ev)' to 'csio_sm_state_t' (aka 'void (*)(void *, unsigned int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
1373 | if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_ready)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/csiostor/csio_lnode.c:1377:29: error: cast from 'void (*)(struct csio_lnode *, enum csio_ln_ev)' to 'csio_sm_state_t' (aka 'void (*)(void *, unsigned int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
1377 | if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_offline)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Move the enum into a shared header so the correct types can be used without the need for casts.
--- drivers/scsi/csiostor/csio_defs.h | 18 ++++++++++++++++-- drivers/scsi/csiostor/csio_lnode.c | 8 ++++---- drivers/scsi/csiostor/csio_lnode.h | 13 ------------- 3 files changed, 20 insertions(+), 19 deletions(-)
drivers/scsi/csiostor/csio_defs.h +16 -2
@@ -73,7 +73,21 @@ csio_list_deleted(struct list_head *list)#define csio_list_prev (elem) (((struct list_head *)(elem))->prev)/* State machine */ -typedef void (*csio_sm_state_t )(void *,uint32_t ); +struct csio_lnode ; + +/* State machine evets */ +enum csio_ln_ev { +CSIO_LNE_NONE = (uint32_t )0 , +CSIO_LNE_LINKUP , +CSIO_LNE_FAB_INIT_DONE , +CSIO_LNE_LINK_DOWN , +CSIO_LNE_DOWN_LINK , +CSIO_LNE_LOGO , +CSIO_LNE_CLOSE , +CSIO_LNE_MAX_EVENT , +}; + +typedef void (*csio_sm_state_t )(struct csio_lnode *ln,enum csio_ln_ev evt);struct csio_sm {struct list_head sm_list;
@@ -83,7 +97,7 @@ struct csio_sm {static inline void csio_set_state (void *smp,void *state) { - ((struct csio_sm *)smp)->sm_state = (csio_sm_state_t )state; + ((struct csio_sm *)smp)->sm_state = state; } static inline void
drivers/scsi/csiostor/csio_lnode.c +4 -4
@@ -1095,7 +1095,7 @@ csio_handle_link_down(struct csio_hw *hw, uint8_t portid, uint32_t fcfi,int csio_is_lnode_ready (struct csio_lnode *ln) { -return (csio_get_state (ln) == ((csio_sm_state_t )csio_lns_ready)); +return (csio_get_state (ln) == csio_lns_ready); }/*****************************************************************************/
@@ -1366,15 +1366,15 @@ csio_free_fcfinfo(struct kref *kref)void csio_lnode_state_to_str (struct csio_lnode *ln,int8_t *str) { -if (csio_get_state (ln) == ((csio_sm_state_t )csio_lns_uninit)) { +if (csio_get_state (ln) == csio_lns_uninit) {strcpy (str,"UNINIT" );return ; } -if (csio_get_state (ln) == ((csio_sm_state_t )csio_lns_ready)) { +if (csio_get_state (ln) == csio_lns_ready) {strcpy (str,"READY" );return ; } -if (csio_get_state (ln) == ((csio_sm_state_t )csio_lns_offline)) { +if (csio_get_state (ln) == csio_lns_offline) {strcpy (str,"OFFLINE" );return ; }
drivers/scsi/csiostor/csio_lnode.h +0 -13
@@ -53,19 +53,6 @@extern int csio_fcoe_rnodes;extern int csio_fdmi_enable; -/* State machine evets */ -enum csio_ln_ev { -CSIO_LNE_NONE = (uint32_t )0 , -CSIO_LNE_LINKUP , -CSIO_LNE_FAB_INIT_DONE , -CSIO_LNE_LINK_DOWN , -CSIO_LNE_DOWN_LINK , -CSIO_LNE_LOGO , -CSIO_LNE_CLOSE , -CSIO_LNE_MAX_EVENT , -}; - -struct csio_fcf_info {struct list_head list;uint8_t priority;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 581/713 i3c: dw: Disable IBI IRQ depends on hot-join and SIR enabling
In reply to Sasha LevinFrom: Dylan Hung <[email protected]>
[ Upstream commit 10201396ef6455a68ac671fa0163205d327ebb70 ]
Disable IBI IRQ signal and status only when hot-join and SIR enabling of all target devices attached to the bus are disabled.
--- drivers/i3c/master/dw-i3c-master.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i3c/master/dw-i3c-master.c +3 -1
@@ -1163,8 +1163,10 @@ static void dw_i3c_master_set_sir_enabled(struct dw_i3c_master *master, global = reg ==0xffffffff ; reg &= ~BIT (idx); }else { - global = reg ==0 ; +bool hj_rejected = !!(readl (master->regs +DEVICE_CTRL ) &DEV_CTRL_HOT_JOIN_NACK ); + reg |=BIT (idx); + global = (reg ==0xffffffff ) && hj_rejected; }writel (reg, master->regs +IBI_SIR_REQ_REJECT );
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 582/713 RDMA/hns: Fix mis-modifying default congestion control algorithm
In reply to Sasha LevinFrom: Luoyouming <[email protected]>
[ Upstream commit d20a7cf9f714f0763efb56f0f2eeca1cb91315ed ]
Commit 27c5fd271d8b ("RDMA/hns: The UD mode can only be configured with DCQCN") adds a check of congest control alorithm for UD. But that patch causes a problem: hr_dev->caps.congest_type is global, used by all QPs, so modifying this field to DCQCN for UD QPs causes other QPs unable to use any other algorithm except DCQCN.
Revert the modification in commit 27c5fd271d8b ("RDMA/hns: The UD mode can only be configured with DCQCN"). Add a new field cong_type to struct hns_roce_qp and configure DCQCN for UD QPs.
--- drivers/infiniband/hw/hns/hns_roce_device.h | 17 +++++++++-------- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 16 ++++++++++------ 2 files changed, 19 insertions(+), 14 deletions(-)
drivers/infiniband/hw/hns/hns_roce_device.h +9 -8
@@ -584,6 +584,13 @@ struct hns_roce_work {u32 queue_num; }; +enum hns_roce_cong_type { +CONG_TYPE_DCQCN , +CONG_TYPE_LDCP , +CONG_TYPE_HC3 , +CONG_TYPE_DIP , +}; +struct hns_roce_qp {struct ib_qp ibqp;struct hns_roce_wq rq;
@@ -627,6 +634,7 @@ struct hns_roce_qp {struct list_head sq_node;/* all send qps are on a list */ struct hns_user_mmap_entry *dwqe_mmap_entry;u32 config; +enum hns_roce_cong_type cong_type; };struct hns_roce_ib_iboe {
@@ -698,13 +706,6 @@ struct hns_roce_eq_table {struct hns_roce_eq *eq; }; -enum cong_type { -CONG_TYPE_DCQCN , -CONG_TYPE_LDCP , -CONG_TYPE_HC3 , -CONG_TYPE_DIP , -}; -struct hns_roce_caps {u64 fw_ver;u8 num_ports;
@@ -834,7 +835,7 @@ struct hns_roce_caps {u16 default_aeq_period;u16 default_aeq_arm_st;u16 default_ceq_arm_st; -enum cong_type cong_type; +enum hns_roce_cong_type cong_type; };enum hns_roce_device_state {
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +10 -6
@@ -4733,12 +4733,15 @@ static int check_cong_type(struct ib_qp *ibqp, struct hns_roce_congestion_algorithm *cong_alg) {struct hns_roce_dev *hr_dev =to_hr_dev (ibqp->device); +struct hns_roce_qp *hr_qp =to_hr_qp (ibqp); -if (ibqp->qp_type ==IB_QPT_UD ) - hr_dev->caps.cong_type =CONG_TYPE_DCQCN ; +if (ibqp->qp_type ==IB_QPT_UD || ibqp->qp_type ==IB_QPT_GSI ) + hr_qp->cong_type =CONG_TYPE_DCQCN ; +else + hr_qp->cong_type = hr_dev->caps.cong_type;/* different congestion types match different configurations */ -switch (hr_dev->caps.cong_type) { +switch (hr_qp->cong_type) {case CONG_TYPE_DCQCN : cong_alg->alg_sel =CONG_DCQCN ; cong_alg->alg_sub_sel =UNSUPPORT_CONG_LEVEL ;
@@ -4766,8 +4769,8 @@ static int check_cong_type(struct ib_qp *ibqp,default :ibdev_warn (&hr_dev->ib_dev,"invalid type(%u) for congestion selection.\n" , - hr_dev->caps.cong_type); - hr_dev->caps.cong_type =CONG_TYPE_DCQCN ; + hr_qp->cong_type); + hr_qp->cong_type =CONG_TYPE_DCQCN ; cong_alg->alg_sel =CONG_DCQCN ; cong_alg->alg_sub_sel =UNSUPPORT_CONG_LEVEL ; cong_alg->dip_vld =DIP_INVALID ;
@@ -4786,6 +4789,7 @@ static int fill_cong_field(struct ib_qp *ibqp, const struct ib_qp_attr *attr,struct hns_roce_congestion_algorithm cong_field;struct ib_device *ibdev = ibqp->device;struct hns_roce_dev *hr_dev =to_hr_dev (ibdev); +struct hns_roce_qp *hr_qp =to_hr_qp (ibqp);u32 dip_idx =0 ;int ret;
@@ -4798,7 +4802,7 @@ static int fill_cong_field(struct ib_qp *ibqp, const struct ib_qp_attr *attr,return ret;hr_reg_write (context,QPC_CONG_ALGO_TMPL_ID , hr_dev->cong_algo_tmpl_id + - hr_dev->caps.cong_type *HNS_ROCE_CONG_SIZE ); + hr_qp->cong_type *HNS_ROCE_CONG_SIZE );hr_reg_clear (qpc_mask,QPC_CONG_ALGO_TMPL_ID );hr_reg_write (&context->ext,QPCEX_CONG_ALG_SEL , cong_field.alg_sel);hr_reg_clear (&qpc_mask->ext,QPCEX_CONG_ALG_SEL );
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 583/713 RDMA/device: Fix a race between mad_client and cm_client init
In reply to Sasha LevinFrom: Shifeng Li <[email protected]>
[ Upstream commit 7a8bccd8b29c321ac181369b42b04fecf05f98e2 ]
The mad_client will be initialized in enable_device_and_get(), while the devices_rwsem will be downgraded to a read semaphore. There is a window that leads to the failed initialization for cm_client, since it can not get matched mad port from ib_mad_port_list, and the matched mad port will be added to the list after that.
mad_client | cm_client ------------------|-------------------------------------------------------- ib_register_device|
enable_device_and_getdown_write(&devices_rwsem)xa_set_mark(&devices, DEVICE_REGISTERED)downgrade_write(&devices_rwsem)
|
|ib_cm_init
|ib_register_client(&cm_client)
|down_read(&devices_rwsem)
|xa_for_each_marked (&devices, DEVICE_REGISTERED)
|add_client_context
|cm_add_one
|ib_register_mad_agent
|ib_get_mad_port
|__ib_get_mad_port
|list_for_each_entry(entry, &ib_mad_port_list, port_list)
|return NULL
|up_read(&devices_rwsem)
|
add_client_context|
ib_mad_init_device|
ib_mad_port_open |
list_add_tail(&port_priv->port_list, &ib_mad_port_list)
up_read(&devices_rwsem)
|Fix it by using down_write(&devices_rwsem) in ib_register_client().
--- drivers/infiniband/core/device.c | 37 +++++++++++++++++++------------- 1 file changed, 22 insertions(+), 15 deletions(-)
drivers/infiniband/core/device.c +22 -15
@@ -1730,7 +1730,7 @@ static int assign_client_id(struct ib_client *client) {int ret; -down_write (&clients_rwsem); +lockdep_assert_held (&clients_rwsem);/* * The add/remove callbacks must be called in FIFO/LIFO order. To * achieve this we assign client_ids so they are sorted in
@@ -1739,14 +1739,11 @@ static int assign_client_id(struct ib_client *client) client->client_id = highest_client_id; ret =xa_insert (&clients, client->client_id, client,GFP_KERNEL );if (ret) - goto out; +return ret; highest_client_id++;xa_set_mark (&clients, client->client_id,CLIENT_REGISTERED ); - -out: -up_write (&clients_rwsem); -return ret; +return 0 ; }static void remove_client_id (struct ib_client *client)
@@ -1776,25 +1773,35 @@ int ib_register_client(struct ib_client *client) {struct ib_device *device;unsigned long index; +bool need_unreg = false;int ret;refcount_set (&client->uses,1 );init_completion (&client->uses_zero); + +/* +* The devices_rwsem is held in write mode to ensure that a racing +* ib_register_device() sees a consisent view of clients and devices. +*/ +down_write (&devices_rwsem); +down_write (&clients_rwsem); ret =assign_client_id (client);if (ret) -return ret; + goto out; -down_read (&devices_rwsem); + need_unreg = true; xa_for_each_marked (&devices, index, device, DEVICE_REGISTERED) { ret =add_client_context (device, client); -if (ret) { -up_read (&devices_rwsem); -ib_unregister_client (client); -return ret; - } +if (ret) + goto out; } -up_read (&devices_rwsem); -return 0 ; + ret =0 ; +out: +up_write (&clients_rwsem); +up_write (&devices_rwsem); +if (need_unreg && ret) +ib_unregister_client (client); +return ret; }EXPORT_SYMBOL (ib_register_client);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 584/713 RDMA/rtrs-clt: Check strnlen return len in sysfs mpath_policy_store()
In reply to Sasha LevinFrom: Alexey Kodanev <[email protected]>
[ Upstream commit 7a7b7f575a25aa68ee934ee8107294487efcb3fe ]
strnlen() may return 0 (e.g. for "\0\n" string), it's better to check the result of strnlen() before using 'len - 1' expression for the 'buf' array index.
Detected using the static analysis tool - Svace.
--- drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c +1 -1
@@ -133,7 +133,7 @@ static ssize_t mpath_policy_store(struct device *dev,/* distinguish "mi" and "min-latency" with length */ len =strnlen (buf,NAME_MAX ); -if (buf[len -1 ] =='\n' ) +if (len && buf[len -1 ] =='\n' ) len--; if (!strncasecmp(buf, "round-robin", 11) ||
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 585/713 scsi: bfa: Fix function pointer type mismatch for hcb_qe->cbfn
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit b69600231f751304db914c63b937f7098ed2895c ]
Some callback functions used here take a boolean argument, others take a status argument. This breaks KCFI type checking, so clang now warns about the function pointer cast:
drivers/scsi/bfa/bfad_bsg.c:2138:29: error: cast from 'void (*)(void *, enum bfa_status)' to 'bfa_cb_cbfn_t' (aka 'void (*)(void *, enum bfa_boolean)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
Assuming the code is actually correct here and the callers always match the argument types of the callee, rework this to replace the explicit cast with a union of the two pointer types. This does not change the behavior of the code, so if something is actually broken here, a larger rework may be necessary.
--- drivers/scsi/bfa/bfa.h | 9 ++++++++- drivers/scsi/bfa/bfa_core.c | 4 +--- drivers/scsi/bfa/bfa_ioc.h | 8 ++++++-- drivers/scsi/bfa/bfad_bsg.c | 11 ++++------- 4 files changed, 19 insertions(+), 13 deletions(-)
drivers/scsi/bfa/bfa.h +8 -1
@@ -20,7 +20,6 @@struct bfa_s ;typedef void (*bfa_isr_func_t ) (struct bfa_s *bfa,struct bfi_msg_s *m); -typedef void (*bfa_cb_cbfn_status_t ) (void *cbarg,bfa_status_t status);/* * Interrupt message handlers
@@ -437,4 +436,12 @@ struct bfa_cb_pending_q_s { (__qe)->data = (__data); \ } while (0) +#define bfa_pending_q_init_status (__qe, __cbfn, __cbarg, __data) do { \ + bfa_q_qe_init(&((__qe)->hcb_qe.qe)); \ + (__qe)->hcb_qe.cbfn_status = (__cbfn); \ + (__qe)->hcb_qe.cbarg = (__cbarg); \ + (__qe)->hcb_qe.pre_rmv = BFA_TRUE; \ + (__qe)->data = (__data); \ +} while (0) +#endif /* __BFA_H__ */
drivers/scsi/bfa/bfa_core.c +1 -3
@@ -1907,15 +1907,13 @@ bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q)struct list_head *qe;struct list_head *qen;struct bfa_cb_qe_s *hcb_qe; -bfa_cb_cbfn_status_t cbfn;list_for_each_safe (qe, qen, comp_q) { hcb_qe = (struct bfa_cb_qe_s *) qe;if (hcb_qe->pre_rmv) {/* qe is invalid after return, dequeue before cbfn() */ list_del (qe); - cbfn = (bfa_cb_cbfn_status_t)(hcb_qe->cbfn); -cbfn (hcb_qe->cbarg, hcb_qe->fw_status); + hcb_qe->cbfn_status (hcb_qe->cbarg, hcb_qe->fw_status); }else hcb_qe->cbfn (hcb_qe->cbarg,BFA_TRUE ); }
drivers/scsi/bfa/bfa_ioc.h +6 -2
@@ -361,14 +361,18 @@ struct bfa_reqq_wait_s {void *cbarg; }; -typedef void (*bfa_cb_cbfn_t ) (void *cbarg,bfa_boolean_t complete); +typedef void (*bfa_cb_cbfn_t ) (void *cbarg,bfa_boolean_t complete); +typedef void (*bfa_cb_cbfn_status_t ) (void *cbarg,bfa_status_t status);/* * Generic BFA callback element. */ struct bfa_cb_qe_s {struct list_head qe; -bfa_cb_cbfn_t cbfn; +union { +bfa_cb_cbfn_status_t cbfn_status; +bfa_cb_cbfn_t cbfn; + };bfa_boolean_t once;bfa_boolean_t pre_rmv;/* set for stack based qe(s) */ bfa_status_t fw_status;/* to access fw status in comp proc */
drivers/scsi/bfa/bfad_bsg.c +4 -7
@@ -2135,8 +2135,7 @@ bfad_iocmd_fcport_get_stats(struct bfad_s *bfad, void *cmd)struct bfa_cb_pending_q_s cb_qe;init_completion (&fcomp.comp); -bfa_pending_q_init (&cb_qe, (bfa_cb_cbfn_t )bfad_hcb_comp, - &fcomp, &iocmd->stats); +bfa_pending_q_init_status (&cb_qe, bfad_hcb_comp, &fcomp, &iocmd->stats);spin_lock_irqsave (&bfad->bfad_lock, flags); iocmd->status =bfa_fcport_get_stats (&bfad->bfa, &cb_qe);spin_unlock_irqrestore (&bfad->bfad_lock, flags);
@@ -2159,7 +2158,7 @@ bfad_iocmd_fcport_reset_stats(struct bfad_s *bfad, void *cmd)struct bfa_cb_pending_q_s cb_qe;init_completion (&fcomp.comp); -bfa_pending_q_init (&cb_qe, (bfa_cb_cbfn_t )bfad_hcb_comp, &fcomp,NULL ); +bfa_pending_q_init_status (&cb_qe, bfad_hcb_comp, &fcomp,NULL );spin_lock_irqsave (&bfad->bfad_lock, flags); iocmd->status =bfa_fcport_clear_stats (&bfad->bfa, &cb_qe);
@@ -2443,8 +2442,7 @@ bfad_iocmd_qos_get_stats(struct bfad_s *bfad, void *cmd)struct bfa_fcport_s *fcport =BFA_FCPORT_MOD (&bfad->bfa);init_completion (&fcomp.comp); -bfa_pending_q_init (&cb_qe, (bfa_cb_cbfn_t )bfad_hcb_comp, - &fcomp, &iocmd->stats); +bfa_pending_q_init_status (&cb_qe, bfad_hcb_comp, &fcomp, &iocmd->stats);spin_lock_irqsave (&bfad->bfad_lock, flags);WARN_ON (!bfa_ioc_get_fcmode (&bfad->bfa.ioc));
@@ -2474,8 +2472,7 @@ bfad_iocmd_qos_reset_stats(struct bfad_s *bfad, void *cmd)struct bfa_fcport_s *fcport =BFA_FCPORT_MOD (&bfad->bfa);init_completion (&fcomp.comp); -bfa_pending_q_init (&cb_qe, (bfa_cb_cbfn_t )bfad_hcb_comp, - &fcomp,NULL ); +bfa_pending_q_init_status (&cb_qe, bfad_hcb_comp, &fcomp,NULL );spin_lock_irqsave (&bfad->bfad_lock, flags);WARN_ON (!bfa_ioc_get_fcmode (&bfad->bfa.ioc));
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 586/713 f2fs: fix to create selinux label during whiteout initialization
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit 40b2d55e045222dd6de2a54a299f682e0f954b03 ]
#generic/700 - output mismatch (see /media/fstests/results//generic/700.out.bad)
# --- tests/generic/700.out 2023-03-28 10:40:42.735529223 +0000 # +++ /media/fstests/results//generic/700.out.bad 2024-02-06 04:37:56.000000000 +0000 # @@ -1,2 +1,4 @@
# QA output created by 700
# +/mnt/scratch_f2fs/f1: security.selinux: No such attribute
# +/mnt/scratch_f2fs/f2: security.selinux: No such attribute
# Silence is golden
# ...
# (Run 'diff -u /media/fstests/tests/generic/700.out /media/fstests/results//generic/700.out.bad' to see the entire diff)
HINT: You _MAY_ be missing kernel fix:
70b589a37e1a xfs: add selinux labels to whiteout inodes
Previously, it missed to create selinux labels during whiteout inode initialization, fix this issue.
--- fs/f2fs/dir.c | 5 +++-- fs/f2fs/f2fs.h | 3 ++- fs/f2fs/namei.c | 25 +++++++++++++++++-------- 3 files changed, 22 insertions(+), 11 deletions(-)
fs/f2fs/dir.c +3 -2
@@ -830,13 +830,14 @@ int f2fs_do_add_link(struct inode *dir, const struct qstr *name,return err; } -int f2fs_do_tmpfile (struct inode *inode,struct inode *dir) +int f2fs_do_tmpfile (struct inode *inode,struct inode *dir, +struct f2fs_filename *fname) {struct page *page;int err =0 ;f2fs_down_write (&F2FS_I (inode)->i_sem); - page =f2fs_init_inode_metadata (inode, dir,NULL ,NULL ); + page =f2fs_init_inode_metadata (inode, dir, fname,NULL );if (IS_ERR (page)) { err =PTR_ERR (page); goto fail;
fs/f2fs/f2fs.h +2 -1
@@ -3572,7 +3572,8 @@ int f2fs_do_add_link(struct inode *dir, const struct qstr *name, struct inode *inode, nid_t ino, umode_t mode);void f2fs_delete_entry (struct f2fs_dir_entry *dentry,struct page *page,struct inode *dir,struct inode *inode); -int f2fs_do_tmpfile (struct inode *inode,struct inode *dir); +int f2fs_do_tmpfile (struct inode *inode,struct inode *dir, +struct f2fs_filename *fname);bool f2fs_empty_dir (struct inode *dir);static inline int f2fs_add_link (struct dentry *dentry,struct inode *inode)
fs/f2fs/namei.c +17 -8
@@ -853,7 +853,7 @@ static int f2fs_mknod(struct mnt_idmap *idmap, struct inode *dir,static int __f2fs_tmpfile (struct mnt_idmap *idmap,struct inode *dir,struct file *file,umode_t mode,bool is_whiteout, -struct inode **new_inode) +struct inode **new_inode,struct f2fs_filename *fname) {struct f2fs_sb_info *sbi =F2FS_I_SB (dir);struct inode *inode;
@@ -881,7 +881,7 @@ static int __f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,if (err) goto out; - err =f2fs_do_tmpfile (inode, dir); + err =f2fs_do_tmpfile (inode, dir, fname);if (err) goto release_out;
@@ -932,22 +932,24 @@ static int f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,if (!f2fs_is_checkpoint_ready (sbi))return -ENOSPC ; - err =__f2fs_tmpfile (idmap, dir, file, mode, false,NULL ); + err =__f2fs_tmpfile (idmap, dir, file, mode, false,NULL ,NULL );return finish_open_simple (file, err); }static int f2fs_create_whiteout (struct mnt_idmap *idmap, -struct inode *dir,struct inode **whiteout) +struct inode *dir,struct inode **whiteout, +struct f2fs_filename *fname) { -return __f2fs_tmpfile (idmap, dir,NULL , -S_IFCHR |WHITEOUT_MODE , true, whiteout); +return __f2fs_tmpfile (idmap, dir,NULL ,S_IFCHR |WHITEOUT_MODE , + true, whiteout, fname); }int f2fs_get_tmpfile (struct mnt_idmap *idmap,struct inode *dir,struct inode **new_inode) { -return __f2fs_tmpfile (idmap, dir,NULL ,S_IFREG , false, new_inode); +return __f2fs_tmpfile (idmap, dir,NULL ,S_IFREG , + false, new_inode,NULL ); } static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
@@ -990,7 +992,14 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir, }if (flags &RENAME_WHITEOUT ) { - err =f2fs_create_whiteout (idmap, old_dir, &whiteout); +struct f2fs_filename fname; + + err =f2fs_setup_filename (old_dir, &old_dentry->d_name, +0 , &fname); +if (err) +return err; + + err =f2fs_create_whiteout (idmap, old_dir, &whiteout, &fname);if (err)return err; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 587/713 f2fs: compress: fix to check zstd compress level correctly in mount option
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit e39602da752cd1d0462e3fa04074146f6f2803f6 ]
f2fs only support to config zstd compress level w/ a positive number due to layout design, but since commit e0c1b49f5b67 ("lib: zstd: Upgrade to latest upstream zstd version 1.4.10"), zstd supports negative compress level, so that zstd_min_clevel() may return a negative number, then w/ below mount option, .compress_level can be configed w/ a negative number, which is not allowed to f2fs, let's add check condition to avoid it.
mount -o compress_algorithm=zstd:4294967295 /dev/sdx /mnt/f2fs
--- fs/f2fs/super.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/f2fs/super.c +8 -2
@@ -663,7 +663,7 @@ static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str)#ifdef CONFIG_F2FS_FS_ZSTD static int f2fs_set_zstd_level (struct f2fs_sb_info *sbi,const char *str) { -unsigned int level; +int level;int len =4 ;if (strlen (str) == len) {
@@ -677,9 +677,15 @@ static int f2fs_set_zstd_level(struct f2fs_sb_info *sbi, const char *str)f2fs_info (sbi,"wrong format, e.g. <alg_name>:<compr_level>" );return -EINVAL ; } -if (kstrtouint (str +1 ,10 , &level)) +if (kstrtoint (str +1 ,10 , &level))return -EINVAL ; +/* f2fs does not support negative compress level now */ +if (level <0 ) { +f2fs_info (sbi,"do not support negative compress level: %d" , level); +return -ERANGE ; + } +if (!f2fs_is_compress_level_valid (COMPRESS_ZSTD , level)) {f2fs_info (sbi,"invalid zstd compress level: %d" , level);return -EINVAL ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 588/713 net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr()
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit d6f4de70f73a106986ee315d7d512539f2f3303a ]
The intent is to check if the strings' are truncated or not. So, >= should be used instead of >, because strlcat() and snprintf() return the length of the output, excluding the trailing NULL.
--- net/sunrpc/addr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sunrpc/addr.c +2 -2
@@ -284,10 +284,10 @@ char *rpc_sockaddr2uaddr(const struct sockaddr *sap, gfp_t gfp_flags) }if (snprintf (portbuf,sizeof (portbuf), -".%u.%u" , port >>8 , port &0xff ) > (int )sizeof (portbuf)) +".%u.%u" , port >>8 , port &0xff ) >= (int )sizeof (portbuf))return NULL ; -if (strlcat (addrbuf, portbuf,sizeof (addrbuf)) >sizeof (addrbuf)) +if (strlcat (addrbuf, portbuf,sizeof (addrbuf)) >=sizeof (addrbuf))return NULL ;return kstrdup (addrbuf, gfp_flags);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 589/713 NFSv4.2: fix nfs4_listxattr kernel BUG at mm/usercopy.c:102
In reply to Sasha LevinFrom: Jorge Mora <[email protected]>
[ Upstream commit 251a658bbfceafb4d58c76b77682c8bf7bcfad65 ]
A call to listxattr() with a buffer size = 0 returns the actual size of the buffer needed for a subsequent call. When size > 0, nfs4_listxattr() does not return an error because either generic_listxattr() or nfs4_listxattr_nfs4_label() consumes exactly all the bytes then size is 0 when calling nfs4_listxattr_nfs4_user() which then triggers the following kernel BUG:
[ 99.403778] kernel BUG at mm/usercopy.c:102! [ 99.404063] Internal error: Oops - BUG: 00000000f2000800 [#1] SMP [ 99.408463] CPU: 0 PID: 3310 Comm: python3 Not tainted 6.6.0-61.fc40.aarch64 #1 [ 99.415827] Call trace: [ 99.415985] usercopy_abort+0x70/0xa0 [ 99.416227] __check_heap_object+0x134/0x158 [ 99.416505] check_heap_object+0x150/0x188 [ 99.416696] __check_object_size.part.0+0x78/0x168 [ 99.416886] __check_object_size+0x28/0x40 [ 99.417078] listxattr+0x8c/0x120 [ 99.417252] path_listxattr+0x78/0xe0 [ 99.417476] __arm64_sys_listxattr+0x28/0x40 [ 99.417723] invoke_syscall+0x78/0x100 [ 99.417929] el0_svc_common.constprop.0+0x48/0xf0 [ 99.418186] do_el0_svc+0x24/0x38 [ 99.418376] el0_svc+0x3c/0x110 [ 99.418554] el0t_64_sync_handler+0x120/0x130 [ 99.418788] el0t_64_sync+0x194/0x198 [ 99.418994] Code: aa0003e3 d000a3e0 91310000 97f49bdb (d4210000)
Issue is reproduced when generic_listxattr() returns 'system.nfs4_acl', thus calling lisxattr() with size = 16 will trigger the bug.
Add check on nfs4_listxattr() to return ERANGE error when it is called with size > 0 and the return value is greater than size.
--- fs/nfs/nfs4proc.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
fs/nfs/nfs4proc.c +10 -6
@@ -10615,29 +10615,33 @@ const struct nfs4_minor_version_ops *nfs_v4_minor_ops[] = {static ssize_t nfs4_listxattr (struct dentry *dentry,char *list,size_t size) {ssize_t error, error2, error3; +size_t left = size; - error =generic_listxattr (dentry, list, size); + error =generic_listxattr (dentry, list, left);if (error <0 )return error;if (list) { list += error; - size -= error; + left -= error; } - error2 =nfs4_listxattr_nfs4_label (d_inode (dentry), list, size); + error2 =nfs4_listxattr_nfs4_label (d_inode (dentry), list, left);if (error2 <0 )return error2;if (list) { list += error2; - size -= error2; + left -= error2; } - error3 =nfs4_listxattr_nfs4_user (d_inode (dentry), list, size); + error3 =nfs4_listxattr_nfs4_user (d_inode (dentry), list, left);if (error3 <0 )return error3; -return error + error2 + error3; + error += error2 + error3; +if (size && error > size) +return -ERANGE ; +return error; }static void nfs4_enable_swap (struct inode *inode)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 590/713 NFSv4.2: fix listxattr maximum XDR buffer size
In reply to Sasha LevinFrom: Jorge Mora <[email protected]>
[ Upstream commit bcac8bff90a6ee1629f90669cdb9d28fb86049b0 ]
Switch order of operations to avoid creating a short XDR buffer:
e.g., buflen = 12, old xdrlen = 12, new xdrlen = 20.
Having a short XDR buffer leads to lxa_maxcount be a few bytes less than what is needed to retrieve the whole list when using a buflen as returned by a call with size = 0:
buflen = listxattr(path, NULL, 0);
buf = malloc(buflen);
buflen = listxattr(path, buf, buflen);For a file with one attribute (name = '123456'), the first call with size = 0 will return buflen = 12 ('user.123456\x00'). The second call with size = 12, sends LISTXATTRS with lxa_maxcount = 12 + 8 (cookie) + 4 (array count) = 24. The XDR buffer needs 8 (cookie) + 4 (array count) + 4 (name count)
+ 6 (name len) + 2 (padding) + 4 (eof) = 28 which is 4 bytes shorter than the lxa_maxcount provided in the call.
--- fs/nfs/nfs42.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/nfs/nfs42.h +5 -2
@@ -55,11 +55,14 @@ int nfs42_proc_removexattr(struct inode *inode, const char *name);* They would be 7 bytes long in the eventual buffer ("user.x\0"), and * 8 bytes long XDR-encoded. * -* Include the trailing eof word as well. +* Include the trailing eof word as well and make the result a multiple +* of 4 bytes. */ static inline u32 nfs42_listxattr_xdrsize (u32 buflen) { -return ((buflen / (XATTR_USER_PREFIX_LEN +2 )) *8 ) +4 ; +u32 size =8 * buflen / (XATTR_USER_PREFIX_LEN +2 ) +4 ; + +return (size +3 ) & ~3 ; }#endif /* CONFIG_NFS_V4_2 */ #endif /* __LINUX_FS_NFS_NFS4_2_H */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 591/713 f2fs: compress: fix to check compress flag w/ .i_sem lock
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit ea59b12ac69774c08aa95cd5b6100700ea0cce97 ]
It needs to check compress flag w/ .i_sem lock, otherwise, compressed inode may be disabled after the check condition, it's not needed to set compress option on non-compress inode.
--- fs/f2fs/file.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/f2fs/file.c +8 -4
@@ -3989,16 +3989,20 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) sizeof(option)))return -EFAULT ; -if (!f2fs_compressed_file (inode) || - option.log_cluster_size <MIN_COMPRESS_LOG_SIZE || - option.log_cluster_size >MAX_COMPRESS_LOG_SIZE || - option.algorithm >=COMPRESS_MAX ) +if (option.log_cluster_size <MIN_COMPRESS_LOG_SIZE || + option.log_cluster_size >MAX_COMPRESS_LOG_SIZE || + option.algorithm >=COMPRESS_MAX )return -EINVAL ;file_start_write (filp);inode_lock (inode);f2fs_down_write (&F2FS_I (inode)->i_sem); +if (!f2fs_compressed_file (inode)) { + ret = -EINVAL ; + goto out; + } +if (f2fs_is_mmap_file (inode) ||get_dirty_pages (inode)) { ret = -EBUSY ; goto out;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 592/713 f2fs: check number of blocks in a current section
In reply to Sasha LevinFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit 7af2df0f67a1469762e59be3726a803882d83f6f ]
In cfd66bb715fd ("f2fs: fix deadloop in foreground GC"), we needed to check the number of blocks in a section instead of the segment.
--- fs/f2fs/segment.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
fs/f2fs/segment.h +8 -9
@@ -573,23 +573,22 @@ static inline bool has_curseg_enough_space(struct f2fs_sb_info *sbi, unsigned int node_blocks, unsigned int dent_blocks) { -unsigned int segno, left_blocks; + unsigned segno, left_blocks;int i; -/* check current node segment */ +/* check current node sections in the worst case. */ for (i =CURSEG_HOT_NODE ; i <=CURSEG_COLD_NODE ; i++) { segno =CURSEG_I (sbi, i)->segno; - left_blocks =f2fs_usable_blks_in_seg (sbi, segno) - -get_seg_entry (sbi, segno)->ckpt_valid_blocks; - + left_blocks =CAP_BLKS_PER_SEC (sbi) - +get_ckpt_valid_blocks (sbi, segno, true);if (node_blocks > left_blocks)return false; } -/* check current data segment */ +/* check current data section for dentry blocks. */ segno =CURSEG_I (sbi,CURSEG_HOT_DATA )->segno; - left_blocks =f2fs_usable_blks_in_seg (sbi, segno) - -get_seg_entry (sbi, segno)->ckpt_valid_blocks; + left_blocks =CAP_BLKS_PER_SEC (sbi) - +get_ckpt_valid_blocks (sbi, segno, true);if (dent_blocks > left_blocks)return false;return true;
@@ -638,7 +637,7 @@ static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi,if (free_secs > upper_secs)return false; -else if (free_secs <= lower_secs) +if (free_secs <= lower_secs)return true;return !curseg_space; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 593/713 watchdog: starfive: Check pm_runtime_enabled() before decrementing usage counter
In reply to Sasha LevinFrom: Ji Sheng Teoh <[email protected]>
[ Upstream commit 8bc22a2f1bf0f402029087fcb53130233a544fed ]
In the probe function, pm_runtime_put_sync() will fail on platform with runtime PM disabled.
Check if runtime PM is enabled before calling pm_runtime_put_sync() to fix it.
--- drivers/watchdog/starfive-wdt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/watchdog/starfive-wdt.c +7 -2
@@ -494,8 +494,13 @@ static int starfive_wdt_probe(struct platform_device *pdev)if (ret) goto err_exit; -if (!early_enable) -pm_runtime_put_sync (&pdev->dev); +if (!early_enable) { +if (pm_runtime_enabled (&pdev->dev)) { + ret =pm_runtime_put_sync (&pdev->dev); +if (ret) + goto err_exit; + } + }return 0 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 594/713 watchdog: stm32_iwdg: initialize default timeout
In reply to Sasha LevinFrom: Ben Wolsieffer <[email protected]>
[ Upstream commit dbd7c0088b7f44aa0b9276ed3449df075a7b5b54 ]
The driver never sets a default timeout value, therefore it is initialized to zero. When CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED is enabled, the watchdog is started during probe. The kernel is supposed to automatically ping the watchdog from this point until userspace takes over, but this does not happen if the configured timeout is zero. A zero timeout causes watchdog_need_worker() to return false, so the heartbeat worker does not run and the system therefore resets soon after the driver is probed.
This patch fixes this by setting an arbitrary non-zero default timeout. The default could be read from the hardware instead, but I didn't see any reason to add this complexity.
This has been tested on an STM32F746.
--- drivers/watchdog/stm32_iwdg.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/watchdog/stm32_iwdg.c +3 -0
@@ -20,6 +20,8 @@#include <linux/platform_device.h> #include <linux/watchdog.h> +#define DEFAULT_TIMEOUT 10 +/* IWDG registers */ #define IWDG_KR 0x00/* Key register */ #define IWDG_PR 0x04/* Prescaler Register */
@@ -248,6 +250,7 @@ static int stm32_iwdg_probe(struct platform_device *pdev) wdd->parent = dev; wdd->info = &stm32_iwdg_info; wdd->ops = &stm32_iwdg_ops; + wdd->timeout =DEFAULT_TIMEOUT ; wdd->min_timeout =DIV_ROUND_UP ((RLR_MIN +1 ) *PR_MIN , wdt->rate); wdd->max_hw_heartbeat_ms = ((RLR_MAX +1 ) * wdt->data->max_prescaler *1000 ) / wdt->rate;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 595/713 f2fs: fix to use correct segment type in f2fs_allocate_data_block()
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit 7324858237829733dec9c670170df2377c5ca6e2 ]
@type in f2fs_allocate_data_block() indicates log header's type, it can be CURSEG_COLD_DATA_PINNED or CURSEG_ALL_DATA_ATGC, rather than type of data/node, however IS_DATASEG()/IS_NODESEG() only accept later one, fix it.
--- fs/f2fs/segment.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/segment.c +2 -2
@@ -3490,12 +3490,12 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,locate_dirty_segment (sbi,GET_SEGNO (sbi, old_blkaddr));locate_dirty_segment (sbi,GET_SEGNO (sbi, *new_blkaddr)); -if (IS_DATASEG (type)) +if (IS_DATASEG (curseg->seg_type))atomic64_inc (&sbi->allocated_data_blocks);up_write (&sit_i->sentry_lock); -if (page &&IS_NODESEG (type)) { +if (page &&IS_NODESEG (curseg->seg_type)) {fill_node_footer_blkaddr (page,NEXT_FREE_BLKADDR (sbi, curseg));f2fs_inode_chksum_set (sbi, page);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 596/713 f2fs: ro: compress: fix to avoid caching unaligned extent
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit 4b99ecd304290c4ef55666a62c89dfb2dbf0b2cd ]
Mapping info from dump.f2fs:
i_addr[0x2d] cluster flag [0xfffffffe : 4294967294] i_addr[0x2e] [0x 10428 : 66600] i_addr[0x2f] [0x 10429 : 66601] i_addr[0x30] [0x 1042a : 66602]
f2fs_io fiemap 37 1 /mnt/f2fs/disk-58390c8c.raw
Previsouly, it missed to align fofs and ofs_in_node to cluster_size, result in adding incorrect read extent cache, fix it.
Before:f2fs_update_read_extent_tree_range: dev = (253,48), ino = 5, pgofs = 37, len = 4, blkaddr = 66600, c_len = 3
After:f2fs_update_read_extent_tree_range: dev = (253,48), ino = 5, pgofs = 36, len = 4, blkaddr = 66600, c_len = 3
--- fs/f2fs/compress.c | 10 ++++++---- fs/f2fs/f2fs.h | 6 ++++-- fs/f2fs/node.c | 20 ++++++++++++++------ 3 files changed, 24 insertions(+), 12 deletions(-)
fs/f2fs/compress.c +6 -4
@@ -1817,16 +1817,18 @@ void f2fs_put_page_dic(struct page *page, bool in_task)* check whether cluster blocks are contiguous, and add extent cache entry * only if cluster blocks are logically and physically contiguous. */ -unsigned int f2fs_cluster_blocks_are_contiguous (struct dnode_of_data *dn) +unsigned int f2fs_cluster_blocks_are_contiguous (struct dnode_of_data *dn, +unsigned int ofs_in_node) { -bool compressed =f2fs_data_blkaddr (dn) ==COMPRESS_ADDR ; +bool compressed =data_blkaddr (dn->inode, dn->node_page, + ofs_in_node) ==COMPRESS_ADDR ;int i = compressed ?1 :0 ;block_t first_blkaddr =data_blkaddr (dn->inode, dn->node_page, - dn->ofs_in_node + i); + ofs_in_node + i);for (i +=1 ; i <F2FS_I (dn->inode)->i_cluster_size; i++) {block_t blkaddr =data_blkaddr (dn->inode, dn->node_page, - dn->ofs_in_node + i); + ofs_in_node + i);if (!__is_valid_data_blkaddr (blkaddr))break ;
fs/f2fs/f2fs.h +4 -2
@@ -4291,7 +4291,8 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc);void f2fs_decompress_end_io (struct decompress_io_ctx *dic,bool failed,bool in_task);void f2fs_put_page_dic (struct page *page,bool in_task); -unsigned int f2fs_cluster_blocks_are_contiguous (struct dnode_of_data *dn); +unsigned int f2fs_cluster_blocks_are_contiguous (struct dnode_of_data *dn, +unsigned int ofs_in_node);int f2fs_init_compress_ctx (struct compress_ctx *cc);void f2fs_destroy_compress_ctx (struct compress_ctx *cc,bool reuse);void f2fs_init_compress_info (struct f2fs_sb_info *sbi);
@@ -4348,7 +4349,8 @@ static inline void f2fs_put_page_dic(struct page *page, bool in_task) {WARN_ON_ONCE (1 ); } -static inline unsigned int f2fs_cluster_blocks_are_contiguous (struct dnode_of_data *dn) {return 0 ; } +static inline unsigned int f2fs_cluster_blocks_are_contiguous ( +struct dnode_of_data *dn,unsigned int ofs_in_node) {return 0 ; }static inline bool f2fs_sanity_check_cluster (struct dnode_of_data *dn) {return false; }static inline int f2fs_init_compress_inode (struct f2fs_sb_info *sbi) {return 0 ; }static inline void f2fs_destroy_compress_inode (struct f2fs_sb_info *sbi) { }
fs/f2fs/node.c +14 -6
@@ -852,21 +852,29 @@ int f2fs_get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode)if (is_inode_flag_set (dn->inode,FI_COMPRESSED_FILE ) &&f2fs_sb_has_readonly (sbi)) { -unsigned int c_len =f2fs_cluster_blocks_are_contiguous (dn); +unsigned int cluster_size =F2FS_I (dn->inode)->i_cluster_size; +unsigned int ofs_in_node = dn->ofs_in_node; +pgoff_t fofs = index; +unsigned int c_len;block_t blkaddr; +/* should align fofs and ofs_in_node to cluster_size */ +if (fofs % cluster_size) { + fofs =round_down (fofs, cluster_size); + ofs_in_node =round_down (ofs_in_node, cluster_size); + } + + c_len =f2fs_cluster_blocks_are_contiguous (dn, ofs_in_node);if (!c_len) goto out; - blkaddr =f2fs_data_blkaddr (dn); + blkaddr =data_blkaddr (dn->inode, dn->node_page, ofs_in_node);if (blkaddr ==COMPRESS_ADDR ) blkaddr =data_blkaddr (dn->inode, dn->node_page, - dn->ofs_in_node +1 ); + ofs_in_node +1 );f2fs_update_read_extent_tree_range_compressed (dn->inode, - index, blkaddr, -F2FS_I (dn->inode)->i_cluster_size, - c_len); + fofs, blkaddr, cluster_size, c_len); } out:return 0 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 597/713 RDMA/mana_ib: Fix bug in creation of dma regions
In reply to Sasha LevinFrom: Konstantin Taranov <[email protected]>
[ Upstream commit e02497fb654689049ba8b46f098f17d5f19e0b3c ]
Use ib_umem_dma_offset() helper to calculate correct dma offset.
--- drivers/infiniband/hw/mana/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mana/main.c +1 -1
@@ -358,7 +358,7 @@ int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem, sizeof(struct gdma_create_dma_region_resp)); create_req->length = umem->length; - create_req->offset_in_page = umem->address & (page_sz -1 ); + create_req->offset_in_page =ib_umem_dma_offset (umem, page_sz); create_req->gdma_page_type =order_base_2 (page_sz) -PAGE_SHIFT ; create_req->page_count = num_pages_total;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 598/713 Input: iqs7222 - add support for IQS7222D v1.1 and v1.2
In reply to Sasha LevinFrom: Jeff LaBundy <[email protected]>
[ Upstream commit 992cf65674778e22436807796b2df927de21bb75 ]
The vendor has introduced two new revisions with slightly different memory maps; update the driver to support them.
--- drivers/input/misc/iqs7222.c | 112 +++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+)
drivers/input/misc/iqs7222.c +112 -0
@@ -620,6 +620,118 @@ static const struct iqs7222_dev_desc iqs7222_devs[] = { }, }, }, + { + .prod_num = IQS7222_PROD_NUM_D, + .fw_major = 1, + .fw_minor = 2, + .touch_link = 1770, + .allow_offset = 9, + .event_offset = 10, + .comms_offset = 11, + .reg_grps = { + [IQS7222_REG_GRP_STAT] = { + .base = IQS7222_SYS_STATUS, + .num_row = 1, + .num_col = 7, + }, + [IQS7222_REG_GRP_CYCLE] = { + .base = 0x8000, + .num_row = 7, + .num_col = 2, + }, + [IQS7222_REG_GRP_GLBL] = { + .base = 0x8700, + .num_row = 1, + .num_col = 3, + }, + [IQS7222_REG_GRP_BTN] = { + .base = 0x9000, + .num_row = 14, + .num_col = 3, + }, + [IQS7222_REG_GRP_CHAN] = { + .base = 0xA000, + .num_row = 14, + .num_col = 4, + }, + [IQS7222_REG_GRP_FILT] = { + .base = 0xAE00, + .num_row = 1, + .num_col = 2, + }, + [IQS7222_REG_GRP_TPAD] = { + .base = 0xB000, + .num_row = 1, + .num_col = 24, + }, + [IQS7222_REG_GRP_GPIO] = { + .base = 0xC000, + .num_row = 3, + .num_col = 3, + }, + [IQS7222_REG_GRP_SYS] = { + .base = IQS7222_SYS_SETUP, + .num_row = 1, + .num_col = 12, + }, + }, + }, + { + .prod_num = IQS7222_PROD_NUM_D, + .fw_major = 1, + .fw_minor = 1, + .touch_link = 1774, + .allow_offset = 9, + .event_offset = 10, + .comms_offset = 11, + .reg_grps = { + [IQS7222_REG_GRP_STAT] = { + .base = IQS7222_SYS_STATUS, + .num_row = 1, + .num_col = 7, + }, + [IQS7222_REG_GRP_CYCLE] = { + .base = 0x8000, + .num_row = 7, + .num_col = 2, + }, + [IQS7222_REG_GRP_GLBL] = { + .base = 0x8700, + .num_row = 1, + .num_col = 3, + }, + [IQS7222_REG_GRP_BTN] = { + .base = 0x9000, + .num_row = 14, + .num_col = 3, + }, + [IQS7222_REG_GRP_CHAN] = { + .base = 0xA000, + .num_row = 14, + .num_col = 4, + }, + [IQS7222_REG_GRP_FILT] = { + .base = 0xAE00, + .num_row = 1, + .num_col = 2, + }, + [IQS7222_REG_GRP_TPAD] = { + .base = 0xB000, + .num_row = 1, + .num_col = 24, + }, + [IQS7222_REG_GRP_GPIO] = { + .base = 0xC000, + .num_row = 3, + .num_col = 3, + }, + [IQS7222_REG_GRP_SYS] = { + .base = IQS7222_SYS_SETUP, + .num_row = 1, + .num_col = 12, + }, + }, + }, { .prod_num = IQS7222_PROD_NUM_D, .fw_major = 0,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 599/713 NFS: Fix nfs_netfs_issue_read() xarray locking for writeback interrupt
In reply to Sasha LevinFrom: Dave Wysochanski <[email protected]>
[ Upstream commit fd5860ab6341506004219b080aea40213b299d2e ]
The loop inside nfs_netfs_issue_read() currently does not disable interrupts while iterating through pages in the xarray to submit for NFS read. This is not safe though since after taking xa_lock, another page in the mapping could be processed for writeback inside an interrupt, and deadlock can occur. The fix is simple and clean if we use xa_for_each_range(), which handles the iteration with RCU while reducing code complexity.
The problem is easily reproduced with the following test:
mount -o vers=3,fsc 127.0.0.1:/export /mnt/nfs dd if=/dev/zero of=/mnt/nfs/file1.bin bs=4096 count=1 echo 3 > /proc/sys/vm/drop_caches
dd if=/mnt/nfs/file1.bin of=/dev/null
umount /mnt/nfs
On the console with a lockdep-enabled kernel a message similar to the following will be seen:
================================
WARNING: inconsistent lock state 6.7.0-lockdbg+ #10 Not tainted
--------------------------------
inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage. test5/1708 [HC0[0]:SC0[0]:HE1:SE1] takes:
ffff888127baa598 (&xa->xa_lock#4){+.?.}-{3:3}, at:
nfs_netfs_issue_read+0x1b2/0x4b0 [nfs]
{IN-SOFTIRQ-W} state was registered at:
lock_acquire+0x144/0x380
_raw_spin_lock_irqsave+0x4e/0xa0
__folio_end_writeback+0x17e/0x5c0
folio_end_writeback+0x93/0x1b0
iomap_finish_ioend+0xeb/0x6a0
blk_update_request+0x204/0x7f0
blk_mq_end_request+0x30/0x1c0
blk_complete_reqs+0x7e/0xa0
__do_softirq+0x113/0x544
__irq_exit_rcu+0xfe/0x120
irq_exit_rcu+0xe/0x20
sysvec_call_function_single+0x6f/0x90
asm_sysvec_call_function_single+0x1a/0x20
pv_native_safe_halt+0xf/0x20
default_idle+0x9/0x20
default_idle_call+0x67/0xa0
do_idle+0x2b5/0x300
cpu_startup_entry+0x34/0x40
start_secondary+0x19d/0x1c0
secondary_startup_64_no_verify+0x18f/0x19b
irq event stamp: 176891
hardirqs last enabled at (176891): [<ffffffffa67a0be4>]
_raw_spin_unlock_irqrestore+0x44/0x60
hardirqs last disabled at (176890): [<ffffffffa67a0899>]
_raw_spin_lock_irqsave+0x79/0xa0
softirqs last enabled at (176646): [<ffffffffa515d91e>]
__irq_exit_rcu+0xfe/0x120
softirqs last disabled at (176633): [<ffffffffa515d91e>]
__irq_exit_rcu+0xfe/0x120other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&xa->xa_lock#4);
<Interrupt>
lock(&xa->xa_lock#4);*** DEADLOCK ***
2 locks held by test5/1708:
#0: ffff888127baa498 (&sb->s_type->i_mutex_key#22){++++}-{4:4}, at:
nfs_start_io_read+0x28/0x90 [nfs]
#1: ffff888127baa650 (mapping.invalidate_lock#3){.+.+}-{4:4}, at:
page_cache_ra_unbounded+0xa4/0x280
stack backtrace:
CPU: 6 PID: 1708 Comm: test5 Kdump: loaded Not tainted 6.7.0-lockdbg+
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-1.fc39
04/01/2014
Call Trace:
dump_stack_lvl+0x5b/0x90
mark_lock+0xb3f/0xd20
__lock_acquire+0x77b/0x3360
_raw_spin_lock+0x34/0x80
nfs_netfs_issue_read+0x1b2/0x4b0 [nfs]
netfs_begin_read+0x77f/0x980 [netfs]
nfs_netfs_readahead+0x45/0x60 [nfs]
nfs_readahead+0x323/0x5a0 [nfs]
read_pages+0xf3/0x5c0
page_cache_ra_unbounded+0x1c8/0x280
filemap_get_pages+0x38c/0xae0
filemap_read+0x206/0x5e0
nfs_file_read+0xb7/0x140 [nfs]
vfs_read+0x2a9/0x460
ksys_read+0xb7/0x140--- fs/nfs/fscache.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
fs/nfs/fscache.c +2 -7
@@ -307,11 +307,11 @@ static void nfs_netfs_issue_read(struct netfs_io_subrequest *sreq)struct inode *inode = sreq->rreq->inode;struct nfs_open_context *ctx = sreq->rreq->netfs_priv;struct page *page; +unsigned long idx;int err;pgoff_t start = (sreq->start + sreq->transferred) >>PAGE_SHIFT ;pgoff_t last = ((sreq->start + sreq->len - sreq->transferred -1 ) >>PAGE_SHIFT ); -XA_STATE (xas, &sreq->rreq->mapping->i_pages, start);nfs_pageio_init_read (&pgio, inode, false, &nfs_async_read_completion_ops);
@@ -322,19 +322,14 @@ static void nfs_netfs_issue_read(struct netfs_io_subrequest *sreq) pgio.pg_netfs = netfs;/* used in completion */ -xas_lock (&xas); -xas_for_each (&xas, page, last) { +xa_for_each_range (&sreq->rreq->mapping->i_pages, idx, page, start, last) {/* nfs_read_add_folio() may schedule() due to pNFS layout and other RPCs */ -xas_pause (&xas); -xas_unlock (&xas); err =nfs_read_add_folio (&pgio, ctx,page_folio (page));if (err <0 ) { netfs->error = err; goto out; } -xas_lock (&xas); } -xas_unlock (&xas); out:nfs_pageio_complete_read (&pgio);nfs_netfs_put (netfs);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 600/713 NFS: Fix an off by one in root_nfs_cat()
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 698ad1a538da0b6bf969cfee630b4e3a026afb87 ]
The intent is to check if 'dest' is truncated or not. So, >= should be used instead of >, because strlcat() returns the length of 'dest' and 'src' excluding the trailing NULL.
--- fs/nfs/nfsroot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfsroot.c +2 -2
@@ -175,10 +175,10 @@ static int __init root_nfs_cat(char *dest, const char *src,size_t len =strlen (dest);if (len && dest[len -1 ] !=',' ) -if (strlcat (dest,"," , destlen) > destlen) +if (strlcat (dest,"," , destlen) >= destlen)return -1 ; -if (strlcat (dest, src, destlen) > destlen) +if (strlcat (dest, src, destlen) >= destlen)return -1 ;return 0 ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 601/713 NFSv4.1/pnfs: fix NFS with TLS in pnfs
In reply to Sasha LevinFrom: Olga Kornievskaia <[email protected]>
[ Upstream commit a35518cae4b325632840bc8c3aa9ad9bac430038 ]
Currently, even though xprtsec=tls is specified and used for operations to MDS, any operations that go to DS travel over unencrypted connection. Or additionally, if more than 1 DS can serve the data, then trunked connections are also done unencrypted.
IN GETDEVINCEINFO, we get an entry for the DS which carries a protocol type (which is TCP), then nfs4_set_ds_client() gets called with TCP instead of TCP with TLS.
Currently, each trunked connection is created and uses clp->cl_hostname value which if TLS is used would get passed up in the handshake upcall, but instead we need to pass in the appropriate trunked address value.
--- fs/nfs/pnfs_nfs.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-)
fs/nfs/pnfs_nfs.c +43 -1
@@ -919,6 +919,8 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv,dprintk ("--> %s DS %s\n" , __func__, ds->ds_remotestr);list_for_each_entry (da, &ds->ds_addrs, da_node) { +char servername[48 ]; +dprintk ("%s: DS %s: trying address %s\n" , __func__, ds->ds_remotestr, da->da_remotestr);
@@ -929,6 +931,7 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv, .dstaddr = (struct sockaddr *)&da->da_addr, .addrlen = da->da_addrlen, .servername = clp->cl_hostname, + .xprtsec = clp->cl_xprtsec, };struct nfs4_add_xprt_data xprtdata = { .clp = clp,
@@ -938,10 +941,45 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv, .data = &xprtdata, }; -if (da->da_transport != clp->cl_proto) +if (da->da_transport != clp->cl_proto && + clp->cl_proto !=XPRT_TRANSPORT_TCP_TLS )continue ; +if (da->da_transport ==XPRT_TRANSPORT_TCP && + mds_srv->nfs_client->cl_proto == +XPRT_TRANSPORT_TCP_TLS ) { +struct sockaddr *addr = + (struct sockaddr *)&da->da_addr; +struct sockaddr_in *sin = + (struct sockaddr_in *)&da->da_addr; +struct sockaddr_in6 *sin6 = + (struct sockaddr_in6 *)&da->da_addr; + +/* for NFS with TLS we need to supply a correct +* servername of the trunked transport, not the +* servername of the main transport stored in +* clp->cl_hostname. And set the protocol to +* indicate to use TLS +*/ + servername[0 ] ='\0' ; +switch (addr->sa_family) { +case AF_INET : +snprintf (servername,sizeof (servername), +"%pI4" , &sin->sin_addr.s_addr); +break ; +case AF_INET6 : +snprintf (servername,sizeof (servername), +"%pI6" , &sin6->sin6_addr); +break ; +default : +/* do not consider this address */ +continue ; + } + xprt_args.ident =XPRT_TRANSPORT_TCP_TLS ; + xprt_args.servername = servername; + }if (da->da_addr.ss_family != clp->cl_addr.ss_family)continue ; +/** * Test this address for session trunking and * add as an alias
@@ -953,6 +991,10 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv,if (xprtdata.cred)put_cred (xprtdata.cred); }else { +if (da->da_transport ==XPRT_TRANSPORT_TCP && + mds_srv->nfs_client->cl_proto == +XPRT_TRANSPORT_TCP_TLS ) + da->da_transport =XPRT_TRANSPORT_TCP_TLS ; clp = nfs4_set_ds_client(mds_srv, &da->da_addr, da->da_addrlen,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 602/713 f2fs: compress: relocate some judgments in f2fs_reserve_compress_blocks
In reply to Sasha LevinFrom: Xiuhong Wang <[email protected]>
[ Upstream commit b7d797d241c154d73ec5523f87f3b06d4f299da1 ]
The following f2fs_io test will get a "0" result instead of -EINVAL, unisoc # ./f2fs_io compress file
unisoc # ./f2fs_io reserve_cblocks file
0
it's not reasonable, so the judgement of atomic_read(&F2FS_I(inode)->i_compr_blocks) should be placed after the judgement of is_inode_flag_set(inode, FI_COMPRESS_RELEASED).
--- fs/f2fs/file.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/f2fs/file.c +3 -4
@@ -3679,9 +3679,6 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)if (ret)return ret; -if (atomic_read (&F2FS_I (inode)->i_compr_blocks)) - goto out; -f2fs_balance_fs (sbi, true);inode_lock (inode);
@@ -3691,6 +3688,9 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) goto unlock_inode; } +if (atomic_read (&F2FS_I (inode)->i_compr_blocks)) + goto unlock_inode; +f2fs_down_write (&F2FS_I (inode)->i_gc_rwsem[WRITE ]);filemap_invalidate_lock (inode->i_mapping);
@@ -3737,7 +3737,6 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) } unlock_inode:inode_unlock (inode); -out:mnt_drop_write_file (filp);if (ret >=0 ) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 603/713 f2fs: compress: fix reserve_cblocks counting error when out of space
In reply to Sasha LevinFrom: Xiuhong Wang <[email protected]>
[ Upstream commit 2f6d721e14b69d6e1251f69fa238b48e8374e25f ]
When a file only needs one direct_node, performing the following operations will cause the file to be unrepairable:
unisoc # ./f2fs_io compress test.apk
unisoc #df -h | grep dm-48/dev/block/dm-48 112G 112G 1.2M 100% /data
unisoc # ./f2fs_io release_cblocks test.apk
924
unisoc # df -h | grep dm-48/dev/block/dm-48 112G 112G 4.8M 100% /data
unisoc # dd if=/dev/random of=file4 bs=1M count=3
3145728 bytes (3.0 M) copied, 0.025 s, 120 M/s
unisoc # df -h | grep dm-48/dev/block/dm-48 112G 112G 1.8M 100% /data
unisoc # ./f2fs_io reserve_cblocks test.apk F2FS_IOC_RESERVE_COMPRESS_BLOCKS failed: No space left on device
adb reboot
unisoc # df -h | grep dm-48/dev/block/dm-48 112G 112G 11M 100% /data
unisoc # ./f2fs_io reserve_cblocks test.apk
0
This is because the file has only one direct_node. After returning to -ENOSPC, reserved_blocks += ret will not be executed. As a result, the reserved_blocks at this time is still 0, which is not the real number of reserved blocks. Therefore, fsck cannot be set to repair the file.
After this patch, the fsck flag will be set to fix this problem.
unisoc # df -h | grep dm-48/dev/block/dm-48 112G 112G 1.8M 100% /data
unisoc # ./f2fs_io reserve_cblocks test.apk F2FS_IOC_RESERVE_COMPRESS_BLOCKS failed: No space left on device
adb reboot then fsck will be executed
unisoc # df -h | grep dm-48/dev/block/dm-48 112G 112G 11M 100% /data
unisoc # ./f2fs_io reserve_cblocks test.apk
924
--- fs/f2fs/file.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
fs/f2fs/file.c +7 -8
@@ -3583,10 +3583,10 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)return ret; } -static int reserve_compress_blocks (struct dnode_of_data *dn,pgoff_t count) +static int reserve_compress_blocks (struct dnode_of_data *dn,pgoff_t count, +unsigned int *reserved_blocks) {struct f2fs_sb_info *sbi =F2FS_I_SB (dn->inode); -unsigned int reserved_blocks =0 ;int cluster_size =F2FS_I (dn->inode)->i_cluster_size;block_t blkaddr;int i;
@@ -3650,12 +3650,12 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count)f2fs_i_compr_blocks_update (dn->inode, compr_blocks, true); - reserved_blocks += reserved; + *reserved_blocks += reserved; next: count -= cluster_size; } -return reserved_blocks; +return 0 ; }static int f2fs_reserve_compress_blocks (struct file *filp,unsigned long arg)
@@ -3716,7 +3716,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) count =min (end_offset - dn.ofs_in_node, last_idx - page_idx); count =round_up (count,F2FS_I (inode)->i_cluster_size); - ret =reserve_compress_blocks (&dn, count); + ret =reserve_compress_blocks (&dn, count, &reserved_blocks);f2fs_put_dnode (&dn);
@@ -3724,13 +3724,12 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)break ; page_idx += count; - reserved_blocks += ret; }filemap_invalidate_unlock (inode->i_mapping);f2fs_up_write (&F2FS_I (inode)->i_gc_rwsem[WRITE ]); -if (ret >=0 ) { +if (!ret) {clear_inode_flag (inode,FI_COMPRESS_RELEASED );inode_set_ctime_current (inode);f2fs_mark_inode_dirty_sync (inode, true);
@@ -3739,7 +3738,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)inode_unlock (inode);mnt_drop_write_file (filp); -if (ret >=0 ) { +if (!ret) { ret =put_user (reserved_blocks, (u64 __user *)arg); }else if (reserved_blocks &&atomic_read (&F2FS_I (inode)->i_compr_blocks)) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 604/713 f2fs: introduce f2fs_invalidate_internal_cache() for cleanup
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit 4e4f1eb9949b10cb7d76370fd27d41f20ef2b32b ]
Just cleanup, no logic changes.
Stable-dep-of: 9f0c4a46be1f ("f2fs: fix to truncate meta inode pages forcely")
--- fs/f2fs/data.c | 8 +++----- fs/f2fs/f2fs.h | 7 +++++++ fs/f2fs/gc.c | 5 ++--- fs/f2fs/segment.c | 14 ++++---------- 4 files changed, 16 insertions(+), 18 deletions(-)
fs/f2fs/data.c +3 -5
@@ -1485,11 +1485,9 @@ static int __allocate_data_block(struct dnode_of_data *dn, int seg_type) old_blkaddr = dn->data_blkaddr;f2fs_allocate_data_block (sbi,NULL , old_blkaddr, &dn->data_blkaddr, &sum, seg_type,NULL ); -if (GET_SEGNO (sbi, old_blkaddr) !=NULL_SEGNO ) { -invalidate_mapping_pages (META_MAPPING (sbi), - old_blkaddr, old_blkaddr); -f2fs_invalidate_compress_page (sbi, old_blkaddr); - } +if (GET_SEGNO (sbi, old_blkaddr) !=NULL_SEGNO ) +f2fs_invalidate_internal_cache (sbi, old_blkaddr); +f2fs_update_data_blkaddr (dn, dn->data_blkaddr);return 0 ; }
fs/f2fs/f2fs.h +7 -0
@@ -4628,6 +4628,13 @@ static inline bool f2fs_is_readonly(struct f2fs_sb_info *sbi)return f2fs_sb_has_readonly (sbi) ||f2fs_readonly (sbi->sb); } +static inline void f2fs_invalidate_internal_cache (struct f2fs_sb_info *sbi, +block_t blkaddr) +{ +invalidate_mapping_pages (META_MAPPING (sbi), blkaddr, blkaddr); +f2fs_invalidate_compress_page (sbi, blkaddr); +} +#define EFSBADCRC EBADMSG/* Bad CRC detected */ #define EFSCORRUPTED EUCLEAN/* Filesystem is corrupted */
fs/f2fs/gc.c +2 -3
@@ -1380,9 +1380,8 @@ static int move_data_block(struct inode *inode, block_t bidx,memcpy (page_address (fio.encrypted_page),page_address (mpage),PAGE_SIZE );f2fs_put_page (mpage,1 ); -invalidate_mapping_pages (META_MAPPING (fio.sbi), - fio.old_blkaddr, fio.old_blkaddr); -f2fs_invalidate_compress_page (fio.sbi, fio.old_blkaddr); + +f2fs_invalidate_internal_cache (fio.sbi, fio.old_blkaddr);set_page_dirty (fio.encrypted_page);if (clear_page_dirty_for_io (fio.encrypted_page))
fs/f2fs/segment.c +4 -10
@@ -2495,8 +2495,7 @@ void f2fs_invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr)if (addr ==NEW_ADDR || addr ==COMPRESS_ADDR )return ; -invalidate_mapping_pages (META_MAPPING (sbi), addr, addr); -f2fs_invalidate_compress_page (sbi, addr); +f2fs_invalidate_internal_cache (sbi, addr);/* add it into sit main buffer */ down_write (&sit_i->sentry_lock);
@@ -3557,11 +3556,8 @@ static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio) reallocate:f2fs_allocate_data_block (fio->sbi, fio->page, fio->old_blkaddr, &fio->new_blkaddr, sum, type, fio); -if (GET_SEGNO (fio->sbi, fio->old_blkaddr) !=NULL_SEGNO ) { -invalidate_mapping_pages (META_MAPPING (fio->sbi), - fio->old_blkaddr, fio->old_blkaddr); -f2fs_invalidate_compress_page (fio->sbi, fio->old_blkaddr); - } +if (GET_SEGNO (fio->sbi, fio->old_blkaddr) !=NULL_SEGNO ) +f2fs_invalidate_internal_cache (fio->sbi, fio->old_blkaddr);/* writeout dirty page into bdev */ f2fs_submit_page_write (fio);
@@ -3757,9 +3753,7 @@ void f2fs_do_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,update_sit_entry (sbi, new_blkaddr,1 ); }if (GET_SEGNO (sbi, old_blkaddr) !=NULL_SEGNO ) { -invalidate_mapping_pages (META_MAPPING (sbi), - old_blkaddr, old_blkaddr); -f2fs_invalidate_compress_page (sbi, old_blkaddr); +f2fs_invalidate_internal_cache (sbi, old_blkaddr);if (!from_gc)update_segment_mtime (sbi, old_blkaddr,0 );update_sit_entry (sbi, old_blkaddr,-1 );
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 605/713 f2fs: fix to truncate meta inode pages forcely
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit 9f0c4a46be1fe9b97dbe66d49204c1371e3ece65 ]
Below race case can cause data corruption:
Thread A GC thread
- gc_data_segment
- ra_data_block
- locked meta_inode page
- f2fs_inplace_write_data
- invalidate_mapping_pages
: fail to invalidate meta_inode page
due to lock failure or dirty|writeback
status
- f2fs_submit_page_bio
: write last dirty data to old blkaddr
- move_data_block
- load old data from meta_inode page
- f2fs_submit_page_write : write old data to new blkaddr
Because invalidate_mapping_pages() will skip invalidating page which has unclear status including locked, dirty, writeback and so on, so we need to use truncate_inode_pages_range() instead of invalidate_mapping_pages() to make sure meta_inode page will be dropped.
--- fs/f2fs/checkpoint.c | 5 +++-- fs/f2fs/f2fs.h | 28 +++++++++++++++++++++++++++- fs/f2fs/segment.c | 5 ++--- include/linux/f2fs_fs.h | 1 + 4 files changed, 33 insertions(+), 6 deletions(-)
fs/f2fs/checkpoint.c +3 -2
@@ -1587,8 +1587,9 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)*/ if (f2fs_sb_has_encrypt (sbi) ||f2fs_sb_has_verity (sbi) ||f2fs_sb_has_compression (sbi)) -invalidate_mapping_pages (META_MAPPING (sbi), -MAIN_BLKADDR (sbi),MAX_BLKADDR (sbi) -1 ); +f2fs_bug_on (sbi, +invalidate_inode_pages2_range (META_MAPPING (sbi), +MAIN_BLKADDR (sbi),MAX_BLKADDR (sbi) -1 ));f2fs_release_ino_entry (sbi, false);
fs/f2fs/f2fs.h +27 -1
@@ -4628,10 +4628,36 @@ static inline bool f2fs_is_readonly(struct f2fs_sb_info *sbi)return f2fs_sb_has_readonly (sbi) ||f2fs_readonly (sbi->sb); } +static inline void f2fs_truncate_meta_inode_pages (struct f2fs_sb_info *sbi, +block_t blkaddr,unsigned int cnt) +{ +bool need_submit = false; +int i =0 ; + +do { +struct page *page; + + page =find_get_page (META_MAPPING (sbi), blkaddr + i); +if (page) { +if (PageWriteback (page)) + need_submit = true; +f2fs_put_page (page,0 ); + } + }while (++i < cnt && !need_submit); + +if (need_submit) +f2fs_submit_merged_write_cond (sbi, sbi->meta_inode, +NULL ,0 ,DATA ); + +truncate_inode_pages_range (META_MAPPING (sbi), +F2FS_BLK_TO_BYTES ((loff_t )blkaddr), +F2FS_BLK_END_BYTES ((loff_t)(blkaddr + cnt -1 ))); +} +static inline void f2fs_invalidate_internal_cache (struct f2fs_sb_info *sbi,block_t blkaddr) { -invalidate_mapping_pages (META_MAPPING (sbi), blkaddr, blkaddr); +f2fs_truncate_meta_inode_pages (sbi, blkaddr,1 );f2fs_invalidate_compress_page (sbi, blkaddr); }
fs/f2fs/segment.c +2 -3
@@ -3651,8 +3651,7 @@ int f2fs_inplace_write_data(struct f2fs_io_info *fio) }if (fio->post_read) -invalidate_mapping_pages (META_MAPPING (sbi), - fio->new_blkaddr, fio->new_blkaddr); +f2fs_truncate_meta_inode_pages (sbi, fio->new_blkaddr,1 );stat_inc_inplace_blocks (fio->sbi);
@@ -3842,7 +3841,7 @@ void f2fs_wait_on_block_writeback_range(struct inode *inode, block_t blkaddr,for (i =0 ; i < len; i++)f2fs_wait_on_block_writeback (inode, blkaddr + i); -invalidate_mapping_pages (META_MAPPING (sbi), blkaddr, blkaddr + len -1 ); +f2fs_truncate_meta_inode_pages (sbi, blkaddr, len); }static int read_compacted_summaries (struct f2fs_sb_info *sbi)
include/linux/f2fs_fs.h +1 -0
@@ -27,6 +27,7 @@#define F2FS_BYTES_TO_BLK (bytes) ((bytes) >> F2FS_BLKSIZE_BITS)#define F2FS_BLK_TO_BYTES (blk) ((blk) << F2FS_BLKSIZE_BITS) +#define F2FS_BLK_END_BYTES (blk) (F2FS_BLK_TO_BYTES(blk + 1) - 1)/* 0, 1(node nid), 2(meta nid) are reserved node id */ #define F2FS_RESERVED_NODE_NUM 3
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 606/713 f2fs: zone: fix to remove pow2 check condition for zoned block device
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit 11bec96afbfbc4679863db55258de440d786821e ]
Commit 2e2c6e9b72ce ("f2fs: remove power-of-two limitation of zoned device") missed to remove pow2 check condition in init_blkz_info(), fix it.
--- fs/f2fs/super.c | 5 ----- 1 file changed, 5 deletions(-)
fs/f2fs/super.c +0 -5
@@ -3944,11 +3944,6 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)return 0 ; zone_sectors =bdev_zone_sectors (bdev); -if (!is_power_of_2 (zone_sectors)) { -f2fs_err (sbi,"F2FS does not support non power of 2 zone sizes\n" ); -return -EINVAL ; - } -if (sbi->blocks_per_blkz && sbi->blocks_per_blkz !=SECTOR_TO_BLOCK (zone_sectors))return -EINVAL ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 607/713 perf/x86/amd/core: Avoid register reset when CPU is dead
In reply to Sasha LevinFrom: Sandipan Das <[email protected]>
[ Upstream commit ad8c91282c95f801c37812d59d2d9eba6899b384 ]
When bringing a CPU online, some of the PMC and LBR related registers are reset. The same is done when a CPU is taken offline although that is unnecessary. This currently happens in the "cpu_dead" callback which is also incorrect as the callback runs on a control CPU instead of the one that is being taken offline. This also affects hibernation and suspend to RAM on some platforms as reported in the link below.
--- arch/x86/events/amd/core.c | 1 - 1 file changed, 1 deletion(-)
arch/x86/events/amd/core.c +0 -1
@@ -604,7 +604,6 @@ static void amd_pmu_cpu_dead(int cpu)kfree (cpuhw->lbr_sel); cpuhw->lbr_sel =NULL ; -amd_pmu_cpu_reset (cpu);if (!x86_pmu.amd_nb_constraints)return ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 608/713 afs: Revert "afs: Hide silly-rename files from userspace"
In reply to Sasha LevinFrom: David Howells <[email protected]>
[ Upstream commit 0aec3847d044273733285dcff90afda89ad461d2 ]
This reverts commit 57e9d49c54528c49b8bffe6d99d782ea051ea534.
This undoes the hiding of .__afsXXXX silly-rename files. The problem with hiding them is that rm can't then manually delete them.
This also reverts commit 5f7a07646655fb4108da527565dcdc80124b14c4 ("afs: Fix endless loop in directory parsing") as that's a bugfix for the above.
--- fs/afs/dir.c | 10 ---------- 1 file changed, 10 deletions(-)
fs/afs/dir.c +0 -10
@@ -474,16 +474,6 @@ static int afs_dir_iterate_block(struct afs_vnode *dvnode,continue ; } -/* Don't expose silly rename entries to userspace. */ -if (nlen >6 && - dire->u.name[0 ] =='.' && - ctx->actor != afs_lookup_filldir && - ctx->actor != afs_lookup_one_filldir && -memcmp (dire->u.name,".__afs" ,6 ) ==0 ) { - ctx->pos = blkoff + next *sizeof (union afs_xdr_dirent ); -continue ; - } -/* found the next entry */ if (!dir_emit(ctx, dire->u.name, nlen, ntohl(dire->u.vnode),
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 609/713 nfs: fix panic when nfs4_ff_layout_prepare_ds() fails
In reply to Sasha LevinFrom: Josef Bacik <[email protected]>
[ Upstream commit 719fcafe07c12646691bd62d7f8d94d657fa0766 ]
We've been seeing the following panic in production
BUG: kernel NULL pointer dereference, address: 0000000000000065 PGD 2f485f067 P4D 2f485f067 PUD 2cc5d8067 PMD 0 RIP: 0010:ff_layout_cancel_io+0x3a/0x90 [nfs_layout_flexfiles] Call Trace: <TASK> ? __die+0x78/0xc0 ? page_fault_oops+0x286/0x380 ? __rpc_execute+0x2c3/0x470 [sunrpc] ? rpc_new_task+0x42/0x1c0 [sunrpc] ? exc_page_fault+0x5d/0x110 ? asm_exc_page_fault+0x22/0x30 ? ff_layout_free_layoutreturn+0x110/0x110 [nfs_layout_flexfiles] ? ff_layout_cancel_io+0x3a/0x90 [nfs_layout_flexfiles] ? ff_layout_cancel_io+0x6f/0x90 [nfs_layout_flexfiles] pnfs_mark_matching_lsegs_return+0x1b0/0x360 [nfsv4] pnfs_error_mark_layout_for_return+0x9e/0x110 [nfsv4] ? ff_layout_send_layouterror+0x50/0x160 [nfs_layout_flexfiles] nfs4_ff_layout_prepare_ds+0x11f/0x290 [nfs_layout_flexfiles] ff_layout_pg_init_write+0xf0/0x1f0 [nfs_layout_flexfiles] __nfs_pageio_add_request+0x154/0x6c0 [nfs] nfs_pageio_add_request+0x26b/0x380 [nfs] nfs_do_writepage+0x111/0x1e0 [nfs] nfs_writepages_callback+0xf/0x30 [nfs] write_cache_pages+0x17f/0x380 ? nfs_pageio_init_write+0x50/0x50 [nfs] ? nfs_writepages+0x6d/0x210 [nfs] ? nfs_writepages+0x6d/0x210 [nfs] nfs_writepages+0x125/0x210 [nfs] do_writepages+0x67/0x220 ? generic_perform_write+0x14b/0x210 filemap_fdatawrite_wbc+0x5b/0x80 file_write_and_wait_range+0x6d/0xc0 nfs_file_fsync+0x81/0x170 [nfs] ? nfs_file_mmap+0x60/0x60 [nfs] __x64_sys_fsync+0x53/0x90 do_syscall_64+0x3d/0x90 entry_SYSCALL_64_after_hwframe+0x46/0xb0
Inspecting the core with drgn I was able to pull this
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog.crashed_thread().stack_trace()[0]
#0 at 0xffffffffa079657a (ff_layout_cancel_io+0x3a/0x84) in ff_layout_cancel_io at fs/nfs/flexfilelayout/flexfilelayout.c:2021:27
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog.crashed_thread().stack_trace()[0]['idx']
(u32)1
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog.crashed_thread().stack_trace()[0]['flseg'].mirror_array[1].mirror_ds
(struct nfs4_ff_layout_ds *)0xffffffffffffffed
This is clear from the stack trace, we call nfs4_ff_layout_prepare_ds() which could error out initializing the mirror_ds, and then we go to clean it all up and our check is only for if (!mirror->mirror_ds). This is inconsistent with the rest of the users of mirror_ds, which have
if (IS_ERR_OR_NULL(mirror_ds))
to keep from tripping over this exact scenario. Fix this up in ff_layout_cancel_io() to make sure we don't panic when we get an error. I also spot checked all the other instances of checking mirror_ds and we appear to be doing the correct checks everywhere, only unconditionally dereferencing mirror_ds when we know it would be valid.
--- fs/nfs/flexfilelayout/flexfilelayout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/flexfilelayout/flexfilelayout.c +1 -1
@@ -2016,7 +2016,7 @@ static void ff_layout_cancel_io(struct pnfs_layout_segment *lseg)for (idx =0 ; idx < flseg->mirror_array_cnt; idx++) { mirror = flseg->mirror_array[idx]; mirror_ds = mirror->mirror_ds; -if (!mirror_ds) +if (IS_ERR_OR_NULL (mirror_ds))continue ; ds = mirror->mirror_ds->ds;if (!ds)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 610/713 io_uring/net: correct the type of variable
In reply to Sasha LevinFrom: Muhammad Usama Anjum <[email protected]>
[ Upstream commit 86bcacc957fc2d0403aa0e652757eec59a5fd7ca ]
The namelen is of type int. It shouldn't be made size_t which is unsigned. The signed number is needed for error checking before use.
--- io_uring/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/net.c +1 -1
@@ -536,7 +536,7 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags)static int io_recvmsg_mshot_prep (struct io_kiocb *req,struct io_async_msghdr *iomsg, -size_t namelen,size_t controllen) +int namelen,size_t controllen) {if ((req->flags & (REQ_F_APOLL_MULTISHOT |REQ_F_BUFFER_SELECT )) == (REQ_F_APOLL_MULTISHOT |REQ_F_BUFFER_SELECT )) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 611/713 bcachefs: Fix build on parisc by avoiding __multi3()
In reply to Sasha LevinFrom: Helge Deller <[email protected]>
commit eba38cc7578bef94865341c73608bdf49193a51d upstream.
The gcc compiler on paric does support the __int128 type, although the architecture does not have native 128-bit support.
The effect is, that the bcachefs u128_square() function will pull in the libgcc __multi3() helper, which breaks the kernel build when bcachefs is built as module since this function isn't currently exported in arch/parisc/kernel/parisc_ksyms.c.
The build failure can be seen in the latest debian kernel build at:
https://buildd.debian.org/status/fetch.php?pkg=linux&arch=hppa&ver=6.7.1-1%7Eexp1&stamp=1706132569&raw=0
We prefer to not export that symbol, so fall back to the optional 64-bit implementation provided by bcachefs and thus avoid usage of __multi3().
--- fs/bcachefs/mean_and_variance.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/bcachefs/mean_and_variance.h +1 -1
@@ -14,7 +14,7 @@* type */ -#ifdef __SIZEOF_INT128__ +#if defined(__SIZEOF_INT128__) && defined(__KERNEL__) && !defined(CONFIG_PARISC) typedef struct { unsigned __int128 v;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 612/713 bcachefs: install fd later to avoid race with close
In reply to Sasha LevinFrom: Mathias Krause <[email protected]>
commit dd839f31d7cd5e04f4111a219024268c6f6973f0 upstream.
Calling fd_install() makes a file reachable for userland, including the possibility to close the file descriptor, which leads to calling its 'release' hook. If that happens before the code had a chance to bump the reference of the newly created task struct, the release callback will call put_task_struct() too early, leading to the premature destruction of the kernel thread.
Avoid that race by calling fd_install() later, after all the setup is done.
--- fs/bcachefs/chardev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/bcachefs/chardev.c +1 -2
@@ -392,10 +392,9 @@ static long bch2_ioctl_data(struct bch_fs *c, goto err; } -fd_install (fd, file); -get_task_struct (ctx->thread);wake_up_process (ctx->thread); +fd_install (fd, file);return fd; err:
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 613/713 bcachefs: check for failure to downgrade
In reply to Sasha LevinFrom: Kent Overstreet <[email protected]>
commit 447c1c01051251853e851bd77f26546488cbc7b7 upstream.
With the upcoming member seq patch, it's now critical that we don't ever write to a superblock that hasn't been version downgraded - failure to update member seq fields will cause split brain detection to fire erroniously.
--- fs/bcachefs/errcode.h | 1 + fs/bcachefs/super-io.c | 12 ++++++++++++ 2 files changed, 13 insertions(+)
fs/bcachefs/errcode.h +1 -0
@@ -224,6 +224,7 @@ x(BCH_ERR_invalid, invalid_bkey) \ x(BCH_ERR_operation_blocked, nocow_lock_blocked) \ x(EIO, btree_node_read_err) \ + x(EIO, sb_not_downgraded) \ x(BCH_ERR_btree_node_read_err, btree_node_read_err_fixable) \ x(BCH_ERR_btree_node_read_err, btree_node_read_err_want_retry) \x (BCH_ERR_btree_node_read_err, btree_node_read_err_must_retry) \
fs/bcachefs/super-io.c +12 -0
@@ -966,6 +966,18 @@ int bch2_write_super(struct bch_fs *c)if (!BCH_SB_INITIALIZED (c->disk_sb.sb)) goto out; +if (le16_to_cpu (c->disk_sb.sb->version) > bcachefs_metadata_version_current) { +struct printbuf buf =PRINTBUF ; +prt_printf (&buf,"attempting to write superblock that wasn't version downgraded (" ); +bch2_version_to_text (&buf,le16_to_cpu (c->disk_sb.sb->version)); +prt_str (&buf," > " ); +bch2_version_to_text (&buf, bcachefs_metadata_version_current); +prt_str (&buf,")" ); +bch2_fs_fatal_error (c,"%s" , buf.buf); +printbuf_exit (&buf); +return -BCH_ERR_sb_not_downgraded; + } +for_each_online_member (ca, c, i) {__set_bit (ca->dev_idx, sb_written.d); ca->sb_write_error =0 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 614/713 bcachefs: fix simulateously upgrading & downgrading
In reply to Sasha LevinFrom: Kent Overstreet <[email protected]>
commit e7999235e6c437b99fad03d8301a4341be0d2bb5 upstream.
--- fs/bcachefs/super-io.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
fs/bcachefs/super-io.c +12 -3
@@ -1085,13 +1085,22 @@ bool bch2_check_version_downgrade(struct bch_fs *c)/* * Downgrade, if superblock is at a higher version than currently * supported: +* +* c->sb will be checked before we write the superblock, so update it as +* well: */ -if (BCH_SB_VERSION_UPGRADE_COMPLETE (c->disk_sb.sb) > bcachefs_metadata_version_current) +if (BCH_SB_VERSION_UPGRADE_COMPLETE (c->disk_sb.sb) > bcachefs_metadata_version_current) {SET_BCH_SB_VERSION_UPGRADE_COMPLETE (c->disk_sb.sb, bcachefs_metadata_version_current); -if (c->sb.version > bcachefs_metadata_version_current) + c->sb.version_upgrade_complete = bcachefs_metadata_version_current; + } +if (c->sb.version > bcachefs_metadata_version_current) { c->disk_sb.sb->version =cpu_to_le16 (bcachefs_metadata_version_current); -if (c->sb.version_min > bcachefs_metadata_version_current) + c->sb.version = bcachefs_metadata_version_current; + } +if (c->sb.version_min > bcachefs_metadata_version_current) { c->disk_sb.sb->version_min =cpu_to_le16 (bcachefs_metadata_version_current); + c->sb.version_min = bcachefs_metadata_version_current; + } c->disk_sb.sb->compat[0 ] &=cpu_to_le64 ((1ULL <<BCH_COMPAT_NR ) -1 );return ret; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 615/713 bcachefs: Fix BTREE_ITER_FILTER_SNAPSHOTS on inodes btree
In reply to Sasha LevinFrom: Kent Overstreet <[email protected]>
commit 204f45140faa0772d2ca1b3de96d1c0fb3db8e77 upstream.
If we're in FILTER_SNAPSHOTS mode and we start scanning a range of the keyspace where no keys are visible in the current snapshot, we have a problem - we'll scan for a very long time before scanning terminates.
Awhile back, this was fixed for most cases with peek_upto() (and assertions that enforce that it's being used).
But the fix missed the fact that the inodes btree is different - every key offset is in a different snapshot tree, not just the inode field.
Fixes:
--- fs/bcachefs/btree_iter.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/bcachefs/btree_iter.c +3 -1
@@ -2094,7 +2094,9 @@ struct bkey_s_c bch2_btree_iter_peek_upto(struct btree_iter *iter, struct bpos e* isn't monotonically increasing before FILTER_SNAPSHOTS, and * that's what we check against in extents mode: */ -if (k.k->p.inode > end.inode) +if (unlikely (!(iter->flags &BTREE_ITER_IS_EXTENTS ) + ?bkey_gt (k.k->p, end) + : k.k->p.inode > end.inode)) goto end; if (iter->update_path &&
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 616/713 comedi: comedi_8255: Correct error in subdevice initialization
In reply to Sasha LevinFrom: Frej Drejhammar <[email protected]>
commit cfa9ba1ae0bef0681833a22d326174fe633caab5 upstream.
The refactoring done in commit 5c57b1ccecc7 ("comedi: comedi_8255: Rework subdevice initialization functions") to the initialization of the io field of struct subdev_8255_private broke all cards using the drivers/comedi/drivers/comedi_8255.c module.
Prior to 5c57b1ccecc7, __subdev_8255_init() initialized the io field in the newly allocated struct subdev_8255_private to the non-NULL callback given to the function, otherwise it used a flag parameter to select between subdev_8255_mmio and subdev_8255_io. The refactoring removed that logic and the flag, as subdev_8255_mm_init() and subdev_8255_io_init() now explicitly pass subdev_8255_mmio and subdev_8255_io respectively to __subdev_8255_init(), only __subdev_8255_init() never sets spriv->io to the supplied callback. That spriv->io is NULL leads to a later BUG:
BUG: kernel NULL pointer dereference, address: 0000000000000000 PGD 0 P4D 0 Oops: 0010 [#1] SMP PTI CPU: 1 PID: 1210 Comm: systemd-udevd Not tainted 6.7.3-x86_64 #1 Hardware name: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX RIP: 0010:0x0 Code: Unable to access opcode bytes at 0xffffffffffffffd6. RSP: 0018:ffffa3f1c02d7b78 EFLAGS: 00010202 RAX: 0000000000000000 RBX: ffff91f847aefd00 RCX: 000000000000009b RDX: 0000000000000003 RSI: 0000000000000001 RDI: ffff91f840f6fc00 RBP: ffff91f840f6fc00 R08: 0000000000000000 R09: 0000000000000001 R10: 0000000000000000 R11: 000000000000005f R12: 0000000000000000 R13: 0000000000000000 R14: ffffffffc0102498 R15: ffff91f847ce6ba8 FS: 00007f72f4e8f500(0000) GS:ffff91f8d5c80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 000000010540e000 CR4: 00000000000406f0 Call Trace: <TASK> ? __die_body+0x15/0x57 ? page_fault_oops+0x2ef/0x33c ? insert_vmap_area.constprop.0+0xb6/0xd5 ? alloc_vmap_area+0x529/0x5ee ? exc_page_fault+0x15a/0x489 ? asm_exc_page_fault+0x22/0x30 __subdev_8255_init+0x79/0x8d [comedi_8255] pci_8255_auto_attach+0x11a/0x139 [8255_pci] comedi_auto_config+0xac/0x117 [comedi] ? __pfx___driver_attach+0x10/0x10 pci_device_probe+0x88/0xf9 really_probe+0x101/0x248 __driver_probe_device+0xbb/0xed driver_probe_device+0x1a/0x72 __driver_attach+0xd4/0xed bus_for_each_dev+0x76/0xb8 bus_add_driver+0xbe/0x1be driver_register+0x9a/0xd8 comedi_pci_driver_register+0x28/0x48 [comedi_pci] ? __pfx_pci_8255_driver_init+0x10/0x10 [8255_pci] do_one_initcall+0x72/0x183 do_init_module+0x5b/0x1e8 init_module_from_file+0x86/0xac __do_sys_finit_module+0x151/0x218 do_syscall_64+0x72/0xdb entry_SYSCALL_64_after_hwframe+0x6e/0x76 RIP: 0033:0x7f72f50a0cb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 47 71 0c 00 f7 d8 64 89 01 48 RSP: 002b:00007ffd47e512d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 RAX: ffffffffffffffda RBX: 0000562dd06ae070 RCX: 00007f72f50a0cb9 RDX: 0000000000000000 RSI: 00007f72f52d32df RDI: 000000000000000e RBP: 0000000000000000 R08: 00007f72f5168b20 R09: 0000000000000000 R10: 0000000000000050 R11: 0000000000000246 R12: 00007f72f52d32df R13: 0000000000020000 R14: 0000562dd06785c0 R15: 0000562dcfd0e9a8 </TASK> Modules linked in: 8255_pci(+) comedi_8255 comedi_pci comedi intel_gtt e100(+) acpi_cpufreq rtc_cmos usbhid CR2: 0000000000000000 ---[ end trace 0000000000000000 ]--- RIP: 0010:0x0 Code: Unable to access opcode bytes at 0xffffffffffffffd6. RSP: 0018:ffffa3f1c02d7b78 EFLAGS: 00010202 RAX: 0000000000000000 RBX: ffff91f847aefd00 RCX: 000000000000009b RDX: 0000000000000003 RSI: 0000000000000001 RDI: ffff91f840f6fc00 RBP: ffff91f840f6fc00 R08: 0000000000000000 R09: 0000000000000001 R10: 0000000000000000 R11: 000000000000005f R12: 0000000000000000 R13: 0000000000000000 R14: ffffffffc0102498 R15: ffff91f847ce6ba8 FS: 00007f72f4e8f500(0000) GS:ffff91f8d5c80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 000000010540e000 CR4: 00000000000406f0
This patch simply corrects the above mistake by initializing spriv->io to the given io callback.
--- drivers/comedi/drivers/comedi_8255.c | 1 + 1 file changed, 1 insertion(+)
drivers/comedi/drivers/comedi_8255.c +1 -0
@@ -159,6 +159,7 @@ static int __subdev_8255_init(struct comedi_device *dev,return -ENOMEM ; spriv->context = context; + spriv->io = io; s->type =COMEDI_SUBD_DIO ; s->subdev_flags =SDF_READABLE |SDF_WRITABLE ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 617/713 comedi: comedi_test: Prevent timers rescheduling during deletion
In reply to Sasha LevinFrom: Ian Abbott <[email protected]>
commit f53641a6e849034a44bf80f50245a75d7a376025 upstream.
The comedi_test devices have a couple of timers (ai_timer and ao_timer) that can be started to simulate hardware interrupts. Their expiry functions normally reschedule the timer. The driver code calls either del_timer_sync() or del_timer() to delete the timers from the queue, but does not currently prevent the timers from rescheduling themselves so synchronized deletion may be ineffective.
Add a couple of boolean members (one for each timer: ai_timer_enable and ao_timer_enable) to the device private data structure to indicate whether the timers are allowed to reschedule themselves. Set the member to true when adding the timer to the queue, and to false when deleting the timer from the queue in the waveform_ai_cancel() and waveform_ao_cancel() functions.
The del_timer_sync() function is also called from the waveform_detach() function, but the timer enable members will already be set to false when that function is called, so no change is needed there.
--- drivers/comedi/drivers/comedi_test.c | 30 ++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)
drivers/comedi/drivers/comedi_test.c +26 -4
@@ -87,6 +87,8 @@ struct waveform_private {struct comedi_device *dev;/* parent comedi device */ u64 ao_last_scan_time;/* time of previous AO scan in usec */ unsigned int ao_scan_period;/* AO scan period in usec */ + bool ai_timer_enable:1; /* should AI timer be running? */ + bool ao_timer_enable:1; /* should AO timer be running? */unsigned short ao_loopbacks[N_CHANS ]; };
@@ -236,8 +238,12 @@ static void waveform_ai_timer(struct timer_list *t) time_increment = devpriv->ai_convert_time - now; else time_increment =1 ; -mod_timer (&devpriv->ai_timer, - jiffies +usecs_to_jiffies (time_increment)); +spin_lock (&dev->spinlock); +if (devpriv->ai_timer_enable) { +mod_timer (&devpriv->ai_timer, + jiffies +usecs_to_jiffies (time_increment)); + } +spin_unlock (&dev->spinlock); } overrun:
@@ -393,9 +399,12 @@ static int waveform_ai_cmd(struct comedi_device *dev,* Seem to need an extra jiffy here, otherwise timer expires slightly * early! */ +spin_lock_bh (&dev->spinlock); + devpriv->ai_timer_enable = true; devpriv->ai_timer.expires = jiffies +usecs_to_jiffies (devpriv->ai_convert_period) +1 ;add_timer (&devpriv->ai_timer); +spin_unlock_bh (&dev->spinlock);return 0 ; }
@@ -404,6 +413,9 @@ static int waveform_ai_cancel(struct comedi_device *dev, {struct waveform_private *devpriv = dev->private; +spin_lock_bh (&dev->spinlock); + devpriv->ai_timer_enable = false; +spin_unlock_bh (&dev->spinlock);if (in_softirq ()) {/* Assume we were called from the timer routine itself. */ del_timer (&devpriv->ai_timer);
@@ -495,8 +507,12 @@ static void waveform_ao_timer(struct timer_list *t)unsigned int time_inc = devpriv->ao_last_scan_time + devpriv->ao_scan_period - now; -mod_timer (&devpriv->ao_timer, - jiffies +usecs_to_jiffies (time_inc)); +spin_lock (&dev->spinlock); +if (devpriv->ao_timer_enable) { +mod_timer (&devpriv->ao_timer, + jiffies +usecs_to_jiffies (time_inc)); + } +spin_unlock (&dev->spinlock); } underrun:
@@ -517,9 +533,12 @@ static int waveform_ao_inttrig_start(struct comedi_device *dev, async->inttrig =NULL ; devpriv->ao_last_scan_time =ktime_to_us (ktime_get ()); +spin_lock_bh (&dev->spinlock); + devpriv->ao_timer_enable = true; devpriv->ao_timer.expires = jiffies +usecs_to_jiffies (devpriv->ao_scan_period);add_timer (&devpriv->ao_timer); +spin_unlock_bh (&dev->spinlock);return 1 ; }
@@ -604,6 +623,9 @@ static int waveform_ao_cancel(struct comedi_device *dev,struct waveform_private *devpriv = dev->private; s->async->inttrig =NULL ; +spin_lock_bh (&dev->spinlock); + devpriv->ao_timer_enable = false; +spin_unlock_bh (&dev->spinlock);if (in_softirq ()) {/* Assume we were called from the timer routine itself. */ del_timer (&devpriv->ao_timer);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 618/713 mei: gsc_proxy: match component when GSC is on different bus
In reply to Sasha LevinFrom: Alexander Usyskin <[email protected]>
commit a0776c214d47ea4f7aaef138095beaa41cff03ef upstream.
On Arrow Lake S systems, MEI is no longer strictly connected to bus 0, while graphics remain exclusively on bus 0. Adapt the component matching logic to accommodate this change:
Original behavior: Required both MEI and graphics to be on the same bus 0.
New behavior: Only enforces graphics to be on bus 0 (integrated), allowing MEI to reside on any bus.
This ensures compatibility with Arrow Lake S and maintains functionality for the legacy systems.
--- drivers/misc/mei/gsc_proxy/mei_gsc_proxy.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/misc/mei/gsc_proxy/mei_gsc_proxy.c +5 -3
@@ -96,7 +96,8 @@ static const struct component_master_ops mei_component_master_ops = {* * The function checks if the device is pci device and * Intel VGA adapter, the subcomponent is SW Proxy -* and the parent of MEI PCI and the parent of VGA are the same PCH device. +* and the VGA is on the bus 0 reserved for built-in devices +* to reject discrete GFX. * * @dev: master device * @subcomponent: subcomponent to match (I915_COMPONENT_SWPROXY)
@@ -123,7 +124,8 @@ static int mei_gsc_proxy_component_match(struct device *dev, int subcomponent,if (subcomponent !=I915_COMPONENT_GSC_PROXY )return 0 ; -return component_compare_dev (dev->parent, ((struct device *)data)->parent); +/* Only built-in GFX */ +return (pdev->bus->number ==0 ); } static int mei_gsc_proxy_probe(struct mei_cl_device *cldev,
@@ -146,7 +148,7 @@ static int mei_gsc_proxy_probe(struct mei_cl_device *cldev, }component_match_add_typed (&cldev->dev, &master_match, - mei_gsc_proxy_component_match, cldev->dev.parent); + mei_gsc_proxy_component_match,NULL );if (IS_ERR_OR_NULL (master_match)) { ret = -ENOMEM ; goto err_exit;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 619/713 remoteproc: stm32: Fix incorrect type in assignment for va
In reply to Sasha LevinFrom: Arnaud Pouliquen <[email protected]>
[ Upstream commit 32381bbccba4c21145c571701f8f7fb1d9b3a92e ]
The sparse tool complains about the attribute conversion between a _iomem void * and a void *:
stm32_rproc.c:122:12: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void *va @@ got void [noderef] __iomem * @@
stm32_rproc.c:122:12: sparse: expected void *va
stm32_rproc.c:122:12: sparse: got void [noderef] __iomem *
Add '__force' to explicitly specify that the cast is intentional. This conversion is necessary to cast to virtual addresses pointer,used, by the remoteproc core.
--- drivers/remoteproc/stm32_rproc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/stm32_rproc.c +2 -2
@@ -120,7 +120,7 @@ static int stm32_rproc_mem_alloc(struct rproc *rproc,void *va;dev_dbg (dev,"map memory: %pad+%zx\n" , &mem->dma, mem->len); - va =ioremap_wc (mem->dma, mem->len); + va = (__force void *)ioremap_wc (mem->dma, mem->len);if (IS_ERR_OR_NULL (va)) {dev_err (dev,"Unable to map memory region: %pad+0x%zx\n" , &mem->dma, mem->len);
@@ -137,7 +137,7 @@ static int stm32_rproc_mem_release(struct rproc *rproc, struct rproc_mem_entry *mem) {dev_dbg (rproc->dev.parent,"unmap memory: %pa\n" , &mem->dma); -iounmap (mem->va); +iounmap ((__force __iomem void *)mem->va);return 0 ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 620/713 remoteproc: stm32: Fix incorrect type assignment returned by stm32_rproc_get_loaded_rsc_tablef
In reply to Sasha LevinFrom: Arnaud Pouliquen <[email protected]>
[ Upstream commit c77b35ce66af25bdd6fde60b62e35b9b316ea5c2 ]
The sparse tool complains about the remove of the _iomem attribute.
stm32_rproc.c:660:17: warning: cast removes address space '__iomem' of expression
Add '__force' to explicitly specify that the cast is intentional. This conversion is necessary to cast to addresses pointer, which are then managed by the remoteproc core as a pointer to a resource_table structure.
--- drivers/remoteproc/stm32_rproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/stm32_rproc.c +1 -1
@@ -657,7 +657,7 @@ stm32_rproc_get_loaded_rsc_table(struct rproc *rproc, size_t *table_sz)* entire area by overwriting it with the initial values stored in rproc->clean_table. */ *table_sz =RSC_TBL_SIZE ; -return (struct resource_table *)ddata->rsc_va; +return (__force struct resource_table *)ddata->rsc_va; }static const struct rproc_ops st_rproc_ops = {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 621/713 iio: pressure: mprls0025pa fix off-by-one enum
In reply to Sasha LevinFrom: Petre Rodan <[email protected]>
[ Upstream commit 9e65506ca9c7ff716c8441a33417820ad61d3a16 ]
Fix off-by-one error in transfer-function property.
The honeywell,transfer-function property takes values between 1-3 so make sure the proper enum gets used.
--- drivers/iio/pressure/mprls0025pa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/pressure/mprls0025pa.c +3 -1
@@ -323,6 +323,7 @@ static int mpr_probe(struct i2c_client *client)struct iio_dev *indio_dev;struct device *dev = &client->dev;s64 scale, offset; +u32 func;if (!i2c_check_functionality (client->adapter,I2C_FUNC_SMBUS_READ_BYTE )) return dev_err_probe(dev, -EOPNOTSUPP,
@@ -362,10 +363,11 @@ static int mpr_probe(struct i2c_client *client)return dev_err_probe (dev, ret,"honeywell,pmax-pascal could not be read\n" ); ret =device_property_read_u32 (dev, -"honeywell,transfer-function" , &data->function); +"honeywell,transfer-function" , &func);if (ret)return dev_err_probe (dev, ret,"honeywell,transfer-function could not be read\n" ); + data->function = func -1 ;if (data->function >MPR_FUNCTION_C ) return dev_err_probe(dev, -EINVAL, "honeywell,transfer-function %d invalid\n",
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 622/713 usb: phy: generic: Get the vbus supply
In reply to Sasha LevinFrom: Sean Anderson <[email protected]>
[ Upstream commit 75fd6485cccef269ac9eb3b71cf56753341195ef ]
While support for working with a vbus was added, the regulator was never actually gotten (despite what was documented). Fix this by actually getting the supply from the device tree.
--- drivers/usb/phy/phy-generic.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/phy/phy-generic.c +7 -0
@@ -268,6 +268,13 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop)return dev_err_probe (dev,PTR_ERR (nop->vbus_draw),"could not get vbus regulator\n" ); + nop->vbus_draw =devm_regulator_get_exclusive (dev,"vbus" ); +if (PTR_ERR (nop->vbus_draw) == -ENODEV ) + nop->vbus_draw =NULL ; +if (IS_ERR (nop->vbus_draw)) +return dev_err_probe (dev,PTR_ERR (nop->vbus_draw), +"could not get vbus regulator\n" ); + nop->dev = dev; nop->phy.dev = nop->dev; nop->phy.label ="nop-xceiv" ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 623/713 tty: vt: fix 20 vs 0x20 typo in EScsiignore
In reply to Sasha LevinFrom: "Jiri Slaby (SUSE)" <[email protected]>
[ Upstream commit 0e6a92f67c8a94707f7bb27ac29e2bdf3e7c167d ]
The if (c >= 20 && c <= 0x3f) test added in commit 7a99565f8732 is wrong. 20 is DC4 in ascii and it makes no sense to consider that as the bottom limit. Instead, it should be 0x20 as in the other test in the commit above. This is supposed to NOT change anything as we handle interesting 20-0x20 asciis far before this if.
So for sakeness, change to 0x20 (which is SPACE).
--- drivers/tty/vt/vt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/vt/vt.c +1 -1
@@ -2469,7 +2469,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) }return ;case EScsiignore: -if (c >=20 && c <=0x3f ) +if (c >=0x20 && c <=0x3f )return ; vc->vc_state = ESnormal;return ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 624/713 serial: max310x: fix syntax error in IRQ error message
In reply to Sasha LevinFrom: Hugo Villeneuve <[email protected]>
[ Upstream commit 8ede8c6f474255b2213cccd7997b993272a8e2f9 ]
Replace g with q.
Helpful when grepping thru source code or logs for "request" keyword.
--- drivers/tty/serial/max310x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/max310x.c +1 -1
@@ -1461,7 +1461,7 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devtyif (!ret)return 0 ; -dev_err (dev,"Unable to reguest IRQ %i\n" , irq); +dev_err (dev,"Unable to request IRQ %i\n" , irq); out_uart:for (i =0 ; i < devtype->nr; i++) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 625/713 tty: serial: samsung: fix tx_empty() to return TIOCSER_TEMT
In reply to Sasha LevinFrom: Tudor Ambarus <[email protected]>
[ Upstream commit 314c2b399288f0058a8c5b6683292cbde5f1531b ]
The core expects for tx_empty() either TIOCSER_TEMT when the tx is empty or 0 otherwise. s3c24xx_serial_txempty_nofifo() might return 0x4, and at least uart_get_lsr_info() tries to clear exactly TIOCSER_TEMT (BIT(1)). Fix tx_empty() to return TIOCSER_TEMT.
--- drivers/tty/serial/samsung_tty.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/tty/serial/samsung_tty.c +2 -3
@@ -987,11 +987,10 @@ static unsigned int s3c24xx_serial_tx_empty(struct uart_port *port)if ((ufstat & info->tx_fifomask) !=0 || (ufstat & info->tx_fifofull))return 0 ; - -return 1 ; +return TIOCSER_TEMT ; } -return s3c24xx_serial_txempty_nofifo (port); +return s3c24xx_serial_txempty_nofifo (port) ?TIOCSER_TEMT :0 ; }/* no modem control lines */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 626/713 arm64: dts: broadcom: bcmbca: bcm4908: drop invalid switch cells
In reply to Sasha LevinFrom: Rafał Miłecki <[email protected]>
[ Upstream commit 27058b95fbb784406ea4c40b20caa3f04937140c ]
Ethernet switch does not have addressable subnodes.
This fixes:arch/arm64/boot/dts/broadcom/bcmbca/bcm4908-asus-gt-ac5300.dtb: ethernet-switch@0: '#address-cells', '#size-cells' do not match any of the regexes: 'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/net/dsa/brcm,sf2.yaml#
--- arch/arm64/boot/dts/broadcom/bcmbca/bcm4908.dtsi | 3 --- 1 file changed, 3 deletions(-)
arch/arm64/boot/dts/broadcom/bcmbca/bcm4908.dtsi +0 -3
@@ -227,9 +227,6 @@ ethernet-switch@0 { brcm,num-gphy = <5>; brcm,num-rgmii-ports = <2>; - #address-cells = <1>; - #size-cells = <0>; - ports: ports { #address-cells = <1>; #size-cells = <0>;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 627/713 coresight: Fix issue where a source device's helpers aren't disabled
In reply to Sasha LevinFrom: James Clark <[email protected]>
[ Upstream commit f68bbe4dcfa303164922bc331d2e8d38ed2d4f23 ]
The linked commit reverts the change that accidentally used some sysfs enable/disable functions from Perf which broke the refcounting, but it also removes the fact that the sysfs disable function disabled the helpers.
Add a new wrapper function that does both which is used by both Perf and sysfs, and label the sysfs disable function appropriately. The naming of all of the functions will be tidied up later to avoid this happening again.
--- drivers/hwtracing/coresight/coresight-core.c | 30 ++++++++++++++----- .../hwtracing/coresight/coresight-etm-perf.c | 2 +- drivers/hwtracing/coresight/coresight-priv.h | 2 +- 3 files changed, 25 insertions(+), 9 deletions(-)
drivers/hwtracing/coresight/coresight-core.c +23 -7
@@ -441,8 +441,26 @@ static void coresight_disable_helpers(struct coresight_device *csdev) } } +/* +* Helper function to call source_ops(csdev)->disable and also disable the +* helpers. +* +* There is an imbalance between coresight_enable_path() and +* coresight_disable_path(). Enabling also enables the source's helpers as part +* of the path, but disabling always skips the first item in the path (which is +* the source), so sources and their helpers don't get disabled as part of that +* function and we need the extra step here. +*/ +void coresight_disable_source (struct coresight_device *csdev,void *data) +{ +if (source_ops (csdev)->disable) +source_ops (csdev)->disable (csdev, data); +coresight_disable_helpers (csdev); +} +EXPORT_SYMBOL_GPL (coresight_disable_source); +/** -* coresight_disable_source - Drop the reference count by 1 and disable +* coresight_disable_source_sysfs - Drop the reference count by 1 and disable * the device if there are no users left. * * @csdev: The coresight device to disable
@@ -451,17 +469,15 @@ static void coresight_disable_helpers(struct coresight_device *csdev)* * Returns true if the device has been disabled. */ -bool coresight_disable_source (struct coresight_device *csdev,void *data) +static bool coresight_disable_source_sysfs (struct coresight_device *csdev, +void *data) {if (atomic_dec_return (&csdev->refcnt) ==0 ) { -if (source_ops (csdev)->disable) -source_ops (csdev)->disable (csdev, data); -coresight_disable_helpers (csdev); +coresight_disable_source (csdev, data); csdev->enable = false; }return !csdev->enable; } -EXPORT_SYMBOL_GPL (coresight_disable_source);/* * coresight_disable_path_from : Disable components in the given path beyond
@@ -1202,7 +1218,7 @@ void coresight_disable(struct coresight_device *csdev)if (ret) goto out; -if (!csdev->enable || !coresight_disable_source (csdev,NULL )) +if (!csdev->enable || !coresight_disable_source_sysfs (csdev,NULL )) goto out;switch (csdev->subtype.source_subtype) {
drivers/hwtracing/coresight/coresight-etm-perf.c +1 -1
@@ -587,7 +587,7 @@ static void etm_event_stop(struct perf_event *event, int mode)return ;/* stop tracer */ -source_ops (csdev)->disable (csdev, event); +coresight_disable_source (csdev, event);/* tell the core */ event->hw.state =PERF_HES_STOPPED ;
drivers/hwtracing/coresight/coresight-priv.h +1 -1
@@ -233,6 +233,6 @@ void coresight_set_percpu_sink(int cpu, struct coresight_device *csdev);struct coresight_device *coresight_get_percpu_sink (int cpu);int coresight_enable_source (struct coresight_device *csdev,enum cs_mode mode,void *data); -bool coresight_disable_source (struct coresight_device *csdev,void *data); +void coresight_disable_source (struct coresight_device *csdev,void *data);#endif
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 628/713 coresight: etm4x: Set skip_power_up in etm4_init_arch_data function
In reply to Sasha LevinFrom: Mao Jinlong <[email protected]>
[ Upstream commit 1bbe0a247e5d72f723daeecf41596bfa99e199f1 ]
skip_power_up is used in etm4_init_arch_data when set lpoverride. So need to set the value of it before calling using it.
--- drivers/hwtracing/coresight/coresight-etm4x-core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +5 -5
@@ -1160,6 +1160,7 @@ static void etm4_init_arch_data(void *info)struct etm4_init_arg *init_arg = info;struct etmv4_drvdata *drvdata;struct csdev_access *csa; +struct device *dev = init_arg->dev;int i; drvdata =dev_get_drvdata (init_arg->dev);
@@ -1173,6 +1174,10 @@ static void etm4_init_arch_data(void *info)if (!etm4_init_csdev_access (drvdata, csa))return ; +if (!csa->io_mem || +fwnode_property_present (dev_fwnode (dev),"qcom,skip-power-up" )) + drvdata->skip_power_up = true; +/* Detect the support for OS Lock before we actually use it */ etm_detect_os_lock (drvdata, csa);
@@ -1998,11 +2003,6 @@ static int etm4_add_coresight_dev(struct etm4_init_arg *init_arg)if (!drvdata->arch)return -EINVAL ; -/* TRCPDCR is not accessible with system instructions. */ -if (!desc.access.io_mem || -fwnode_property_present (dev_fwnode (dev),"qcom,skip-power-up" )) - drvdata->skip_power_up = true; - major =ETM_ARCH_MAJOR_VERSION (drvdata->arch); minor =ETM_ARCH_MINOR_VERSION (drvdata->arch);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 629/713 kconfig: fix infinite loop when expanding a macro at the end of file
In reply to Sasha LevinFrom: Masahiro Yamada <[email protected]>
[ Upstream commit af8bbce92044dc58e4cc039ab94ee5d470a621f5 ]
A macro placed at the end of a file with no newline causes an infinite loop.
[Test Kconfig]
$(info,hello)
\ No newline at end of file
I realized that flex-provided input() returns 0 instead of EOF when it reaches the end of a file.
--- scripts/kconfig/lexer.l | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
scripts/kconfig/lexer.l +5 -2
@@ -302,8 +302,11 @@ static char *expand_token(const char *in, size_t n) new_string(); append_string(in, n); - /* get the whole line because we do not know the end of token. */ - while ((c = input()) != EOF) { + /* + * get the whole line because we do not know the end of token. + * input() returns 0 (not EOF!) when it reachs the end of file. + */ + while ((c = input()) != 0) { if (c == '\n') { unput(c); break;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 630/713 iio: gts-helper: Fix division loop
In reply to Sasha LevinFrom: Matti Vaittinen <[email protected]>
[ Upstream commit bb76cc45dcdfcd962a5994b8fe19ab74fc6c3c3a ]
The loop based 64bit division may run for a long time when dividend is a lot bigger than the divider. Replace the division loop by the div64_u64() which implementation may be significantly faster.
--- drivers/iio/industrialio-gts-helper.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/iio/industrialio-gts-helper.c +1 -14
@@ -34,24 +34,11 @@static int iio_gts_get_gain (const u64 max,const u64 scale) {u64 full = max; -int tmp =1 ;if (scale > full || !scale)return -EINVAL ; -if (U64_MAX - full < scale) { -/* Risk of overflow */ -if (full - scale < scale) -return 1 ; - - full -= scale; - tmp++; - } - -while (full > scale * (u64 )tmp) - tmp++; - -return tmp; +return div64_u64 (full, scale); }/**
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 631/713 bus: mhi: ep: check the correct variable in mhi_ep_register_controller()
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit 27711860c54ccb5e80719df684f49f0bf3f8fb51 ]
There is a copy and paste bug here so it checks "ev_ring_el_cache" instead of "ring_item_cache".
--- drivers/bus/mhi/ep/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/mhi/ep/main.c +1 -1
@@ -1427,7 +1427,7 @@ int mhi_ep_register_controller(struct mhi_ep_cntrl *mhi_cntrl, mhi_cntrl->ring_item_cache =kmem_cache_create ("mhi_ep_ring_item" ,sizeof (struct mhi_ep_ring_item ),0 ,0 ,NULL ); -if (!mhi_cntrl->ev_ring_el_cache) { +if (!mhi_cntrl->ring_item_cache) { ret = -ENOMEM ; goto err_destroy_tre_buf_cache; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 632/713 hwtracing: hisi_ptt: Move type check to the beginning of hisi_ptt_pmu_event_init()
In reply to Sasha LevinFrom: Yang Jihong <[email protected]>
[ Upstream commit 06226d120a28f146abd3637799958a4dc4dbb7a1 ]
When perf_init_event() calls perf_try_init_event() to init pmu driver, searches for the next pmu driver only when the return value is -ENOENT. Therefore, hisi_ptt_pmu_event_init() needs to check the type at the beginning of the function.
Otherwise, in the case of perf-task mode, perf_try_init_event() returns -EOPNOTSUPP and skips subsequent pmu drivers, causes perf_init_event() to fail.
--- drivers/hwtracing/ptt/hisi_ptt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hwtracing/ptt/hisi_ptt.c +3 -3
@@ -995,6 +995,9 @@ static int hisi_ptt_pmu_event_init(struct perf_event *event)int ret;u32 val; +if (event->attr.type != hisi_ptt->hisi_ptt_pmu.type) +return -ENOENT ; +if (event->cpu <0 ) {dev_dbg (event->pmu->dev,"Per-task mode not supported\n" );return -EOPNOTSUPP ;
@@ -1003,9 +1006,6 @@ static int hisi_ptt_pmu_event_init(struct perf_event *event)if (event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ; -if (event->attr.type != hisi_ptt->hisi_ptt_pmu.type) -return -ENOENT ; - ret =hisi_ptt_trace_valid_filter (hisi_ptt, event->attr.config);if (ret <0 )return ret;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 633/713 rtc: mt6397: select IRQ_DOMAIN instead of depending on it
In reply to Sasha LevinFrom: Randy Dunlap <[email protected]>
[ Upstream commit 544c42f798e1651dcb04fb0395219bf0f1c2607e ]
IRQ_DOMAIN is a hidden (not user visible) symbol. Users cannot set it directly thru "make *config", so drivers should select it instead of depending on it if they need it.
Relying on it being set for a dependency is risky.
Consistently using "select" or "depends on" can also help reduce Kconfig circular dependency issues.
Therefore, change the use of "depends on" for IRQ_DOMAIN to "select" for RTC_DRV_MT6397.
--- drivers/rtc/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rtc/Kconfig +2 -1
@@ -1832,7 +1832,8 @@ config RTC_DRV_MT2712 config RTC_DRV_MT6397 tristate "MediaTek PMIC based RTC" - depends on MFD_MT6397 || (COMPILE_TEST && IRQ_DOMAIN) + depends on MFD_MT6397 || COMPILE_TEST + select IRQ_DOMAIN help This selects the MediaTek(R) RTC driver. RTC is part of MediaTek MT6397 PMIC. You should enable MT6397 PMIC MFD before select
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 634/713 serial: 8250_exar: Don't remove GPIO device on suspend
In reply to Sasha LevinFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 73b5a5c00be39e23b194bad10e1ea8bb73eee176 ]
It seems a copy&paste mistake that suspend callback removes the GPIO device. There is no counterpart of this action, means once suspended there is no more GPIO device available untile full unbind-bind cycle is performed. Remove suspicious GPIO device removal in suspend.
--- drivers/tty/serial/8250/8250_exar.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/8250/8250_exar.c +1 -4
@@ -753,6 +753,7 @@ static void exar_pci_remove(struct pci_dev *pcidev)for (i =0 ; i < priv->nr; i++)serial8250_unregister_port (priv->line[i]); +/* Ensure that every init quirk is properly torn down */ if (priv->board->exit) priv->board->exit (pcidev); }
@@ -767,10 +768,6 @@ static int __maybe_unused exar_suspend(struct device *dev)if (priv->line[i] >=0 )serial8250_suspend_port (priv->line[i]); -/* Ensure that every init quirk is properly torn down */ -if (priv->board->exit) - priv->board->exit (pcidev); -return 0 ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 635/713 staging: greybus: fix get_channel_from_mode() failure path
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit 34164202a5827f60a203ca9acaf2d9f7d432aac8 ]
The get_channel_from_mode() function is supposed to return the channel which matches the mode. But it has a bug where if it doesn't find a matching channel then it returns the last channel. It should return NULL instead.
Also remove an unnecessary NULL check on "channel".
--- drivers/staging/greybus/light.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/greybus/light.c +4 -4
@@ -100,15 +100,15 @@ static struct led_classdev *get_channel_cdev(struct gb_channel *channel)static struct gb_channel *get_channel_from_mode (struct gb_light *light,u32 mode) { -struct gb_channel *channel =NULL ; +struct gb_channel *channel;int i;for (i =0 ; i < light->channels_count; i++) { channel = &light->channels[i]; -if (channel && channel->mode == mode) -break ; +if (channel->mode == mode) +return channel; } -return channel; +return NULL ; } static int __gb_lights_flash_intensity_set(struct gb_channel *channel,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 636/713 usb: gadget: net2272: Use irqflags in the call to net2272_probe_fin
In reply to Sasha LevinFrom: Colin Ian King <[email protected]>
[ Upstream commit 600556809f04eb3bbccd05218215dcd7b285a9a9 ]
Currently the variable irqflags is being set but is not being used, it appears it should be used in the call to net2272_probe_fin rather than IRQF_TRIGGER_LOW being used. Kudos to Uwe Kleine-König for suggesting the fix.
Cleans up clang scan build warning:drivers/usb/gadget/udc/net2272.c:2610:15: warning: variable 'irqflags' set but not used [-Wunused-but-set-variable]
--- drivers/usb/gadget/udc/net2272.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/net2272.c +1 -1
@@ -2650,7 +2650,7 @@ net2272_plat_probe(struct platform_device *pdev) goto err_req; } - ret =net2272_probe_fin (dev,IRQF_TRIGGER_LOW ); + ret =net2272_probe_fin (dev, irqflags);if (ret) goto err_io;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 637/713 char: xilinx_hwicap: Fix NULL vs IS_ERR() bug
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit 316459ba4051fd91237171fdca88920128a646f1 ]
The devm_platform_ioremap_resource() function returns error pointers. It never returns NULL. Update the check accordingly.
--- drivers/char/xilinx_hwicap/xilinx_hwicap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/xilinx_hwicap/xilinx_hwicap.c +2 -2
@@ -639,8 +639,8 @@ static int hwicap_setup(struct platform_device *pdev, int id,dev_set_drvdata (dev, (void *)drvdata); drvdata->base_address =devm_platform_ioremap_resource (pdev,0 ); -if (!drvdata->base_address) { - retval = -ENODEV ; +if (IS_ERR (drvdata->base_address)) { + retval =PTR_ERR (drvdata->base_address); goto failed; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 638/713 x86/hyperv: Use per cpu initial stack for vtl context
In reply to Sasha LevinFrom: Saurabh Sengar <[email protected]>
[ Upstream commit 2b4b90e053a29057fb05ba81acce26bddce8d404 ]
Currently, the secondary CPUs in Hyper-V VTL context lack support for parallel startup. Therefore, relying on the single initial_stack fetched from the current task structure suffices for all vCPUs.
However, common initial_stack risks stack corruption when parallel startup is enabled. In order to facilitate parallel startup, use the initial_stack from the per CPU idle thread instead of the current task.
Message-ID: <[email protected]>
--- arch/x86/hyperv/hv_vtl.c | 19 +++++++++++++++---- drivers/hv/Kconfig | 1 + 2 files changed, 16 insertions(+), 4 deletions(-)
arch/x86/hyperv/hv_vtl.c +15 -4
@@ -12,6 +12,7 @@#include <asm/i8259.h> #include <asm/mshyperv.h> #include <asm/realmode.h> +#include <../kernel/smpboot.h> extern struct boot_params boot_params;static struct real_mode_header hv_vtl_real_mode_header;
@@ -64,7 +65,7 @@ static void hv_vtl_ap_entry(void) ((secondary_startup_64_fn )secondary_startup_64)(&boot_params, &boot_params); } -static int hv_vtl_bringup_vcpu (u32 target_vp_index,u64 eip_ignored) +static int hv_vtl_bringup_vcpu (u32 target_vp_index,int cpu,u64 eip_ignored) {u64 status;int ret =0 ;
@@ -78,7 +79,9 @@ static int hv_vtl_bringup_vcpu(u32 target_vp_index, u64 eip_ignored)struct ldttss_desc *ldt;struct desc_struct *gdt; -u64 rsp = current->thread.sp; +struct task_struct *idle =idle_thread_get (cpu); +u64 rsp = (unsigned long )idle->thread.sp; +u64 rip = (u64)&hv_vtl_ap_entry;native_store_gdt (&gdt_ptr);
@@ -205,7 +208,15 @@ static int hv_vtl_apicid_to_vp_id(u32 apic_id)static int hv_vtl_wakeup_secondary_cpu (u32 apicid,unsigned long start_eip) { -int vp_id; +int vp_id, cpu; + +/* Find the logical CPU for the APIC ID */ +for_each_present_cpu (cpu) { +if (arch_match_cpu_phys_id (cpu, apicid)) +break ; + } +if (cpu >= nr_cpu_ids) +return -EINVAL ;pr_debug ("Bringing up CPU with APIC ID %d in VTL2...\n" , apicid); vp_id =hv_vtl_apicid_to_vp_id (apicid);
@@ -219,7 +230,7 @@ static int hv_vtl_wakeup_secondary_cpu(u32 apicid, unsigned long start_eip)return -EINVAL ; } -return hv_vtl_bringup_vcpu (vp_id, start_eip); +return hv_vtl_bringup_vcpu (vp_id, cpu, start_eip); }int __init hv_vtl_early_init (void )
drivers/hv/Kconfig +1 -0
@@ -16,6 +16,7 @@ config HYPERV config HYPERV_VTL_MODE bool "Enable Linux to boot in VTL context" depends on X86_64 && HYPERV + depends on SMP default n help Virtual Secure Mode (VSM) is a set of hypervisor capabilities and
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 639/713 ASoC: tlv320adc3xxx: Don't strip remove function when driver is builtin
In reply to Sasha LevinFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit f31e0d0c2cad23e0cc48731634f85bb2d8707790 ]
Using __exit for the remove function results in the remove callback being discarded with SND_SOC_TLV320ADC3XXX=y. When such a device gets unbound (e.g. using sysfs or hotplug), the driver is just removed without the cleanup being performed. This results in resource leaks. Fix it by compiling in the remove callback unconditionally.
This also fixes a W=1 modpost warning:
WARNING: modpost: sound/soc/codecs/snd-soc-tlv320adc3xxx: section mismatch in reference: adc3xxx_i2c_driver+0x10 (section: .data) -> adc3xxx_i2c_remove (section: .exit.text)
(which only happens with SND_SOC_TLV320ADC3XXX=m).
--- sound/soc/codecs/tlv320adc3xxx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/tlv320adc3xxx.c +2 -2
@@ -1429,7 +1429,7 @@ static int adc3xxx_i2c_probe(struct i2c_client *i2c)return ret; } -static void __exit adc3xxx_i2c_remove(struct i2c_client *client) +static void adc3xxx_i2c_remove (struct i2c_client *client) {struct adc3xxx *adc3xxx =i2c_get_clientdata (client);
@@ -1452,7 +1452,7 @@ static struct i2c_driver adc3xxx_i2c_driver = { .of_match_table = tlv320adc3xxx_of_match, }, .probe = adc3xxx_i2c_probe, - .remove = __exit_p(adc3xxx_i2c_remove), + .remove = adc3xxx_i2c_remove, .id_table = adc3xxx_i2c_id, };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 640/713 thermal/drivers/mediatek/lvts_thermal: Fix a memory leak in an error handling path
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit ca93bf607a44c1f009283dac4af7df0d9ae5e357 ]
If devm_krealloc() fails, then 'efuse' is leaking. So free it to avoid a leak.
--- drivers/thermal/mediatek/lvts_thermal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/thermal/mediatek/lvts_thermal.c +3 -1
@@ -719,8 +719,10 @@ static int lvts_calibration_read(struct device *dev, struct lvts_domain *lvts_td lvts_td->calib =devm_krealloc (dev, lvts_td->calib, lvts_td->calib_len + len,GFP_KERNEL ); -if (!lvts_td->calib) +if (!lvts_td->calib) { +kfree (efuse);return -ENOMEM ; + }memcpy (lvts_td->calib + lvts_td->calib_len, efuse, len);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 641/713 thermal/drivers/qoriq: Fix getting tmu range
In reply to Sasha LevinFrom: Peng Fan <[email protected]>
[ Upstream commit 4d0642074c67ed9928e9d68734ace439aa06e403 ]
TMU Version 1 has 4 TTRCRs, while TMU Version >=2 has 16 TTRCRs. So limit the len to 4 will report "invalid range data" for i.MX93.
This patch drop the local array with allocated ttrcr array and able to support larger tmu ranges.
--- drivers/thermal/qoriq_thermal.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/thermal/qoriq_thermal.c +8 -4
@@ -57,6 +57,9 @@#define REGS_TTRnCR (n) (0xf10 + 4 * (n))/* Temperature Range n * Control Register */ +#define NUM_TTRCR_V1 4 +#define NUM_TTRCR_MAX 16 +#define REGS_IPBRR (n) (0xbf8 + 4 * (n))/* IP Block Revision * Register n */
@@ -71,6 +74,7 @@ struct qoriq_sensor {struct qoriq_tmu_data {int ver; +u32 ttrcr[NUM_TTRCR_MAX ];struct regmap *regmap;struct clk *clk;struct qoriq_sensor sensor[SITES_MAX ];
@@ -182,17 +186,17 @@ static int qoriq_tmu_calibration(struct device *dev, struct qoriq_tmu_data *data) {int i, val, len; -u32 range[4 ];const u32 *calibration;struct device_node *np = dev->of_node; len =of_property_count_u32_elems (np,"fsl,tmu-range" ); -if (len <0 || len >4 ) { +if (len <0 || (data->ver ==TMU_VER1 && len >NUM_TTRCR_V1 ) || + (data->ver >TMU_VER1 && len >NUM_TTRCR_MAX )) {dev_err (dev,"invalid range data.\n" );return len; } - val =of_property_read_u32_array (np,"fsl,tmu-range" , range, len); + val =of_property_read_u32_array (np,"fsl,tmu-range" , data->ttrcr, len);if (val !=0 ) {dev_err (dev,"failed to read range data.\n" );return val;
@@ -200,7 +204,7 @@ static int qoriq_tmu_calibration(struct device *dev,/* Init temperature range registers */ for (i =0 ; i < len; i++) -regmap_write (data->regmap,REGS_TTRnCR (i), range[i]); +regmap_write (data->regmap,REGS_TTRnCR (i), data->ttrcr[i]); calibration =of_get_property (np,"fsl,tmu-calibration" , &len);if (calibration ==NULL || len %8 ) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 642/713 io_uring: don't save/restore iowait state
In reply to Sasha LevinFrom: Jens Axboe <[email protected]>
[ Upstream commit 6f0974eccbf78baead1735722c4f1ee3eb9422cd ]
This kind of state is per-syscall, and since we're doing the waiting off entering the io_uring_enter(2) syscall, there's no way that iowait can already be set for this case. Simplify it by setting it if we need to, and always clearing it to 0 when done.
--- io_uring/io_uring.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
io_uring/io_uring.c +2 -3
@@ -2508,7 +2508,7 @@ static bool current_pending_io(void)static inline int io_cqring_wait_schedule (struct io_ring_ctx *ctx,struct io_wait_queue *iowq) { -int io_wait, ret; +int ret;if (unlikely (READ_ONCE (ctx->check_cq)))return 1 ;
@@ -2526,7 +2526,6 @@ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,* can take into account that the task is waiting for IO - turns out * to be important for low QD IO. */ - io_wait = current->in_iowait;if (current_pending_io ()) current->in_iowait =1 ; ret =0 ;
@@ -2534,7 +2533,7 @@ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,schedule (); else if (!schedule_hrtimeout(&iowq->timeout, HRTIMER_MODE_ABS)) ret = -ETIME ; - current->in_iowait = io_wait; + current->in_iowait =0 ;return ret; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 643/713 spi: lpspi: Avoid potential use-after-free in probe()
In reply to Sasha LevinFrom: Alexander Sverdlin <[email protected]>
[ Upstream commit 2ae0ab0143fcc06190713ed81a6486ed0ad3c861 ]
fsl_lpspi_probe() is allocating/disposing memory manually with spi_alloc_host()/spi_alloc_target(), but uses devm_spi_register_controller(). In case of error after the latter call the memory will be explicitly freed in the probe function by spi_controller_put() call, but used afterwards by "devm" management outside probe() (spi_unregister_controller() <- devm_spi_unregister() below).
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000070 ... Call trace: kernfs_find_ns kernfs_find_and_get_ns sysfs_remove_group sysfs_remove_groups device_remove_attrs device_del spi_unregister_controller devm_spi_unregister release_nodes devres_release_all really_probe driver_probe_device __device_attach_driver bus_for_each_drv __device_attach device_initial_probe bus_probe_device deferred_probe_work_func process_one_work worker_thread kthread ret_from_fork
--- drivers/spi/spi-fsl-lpspi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/spi/spi-fsl-lpspi.c +4 -4
@@ -830,11 +830,11 @@ static int fsl_lpspi_probe(struct platform_device *pdev) is_target =of_property_read_bool ((&pdev->dev)->of_node,"spi-slave" );if (is_target) - controller =spi_alloc_target (&pdev->dev, -sizeof (struct fsl_lpspi_data )); + controller =devm_spi_alloc_target (&pdev->dev, +sizeof (struct fsl_lpspi_data ));else - controller =spi_alloc_host (&pdev->dev, -sizeof (struct fsl_lpspi_data )); + controller =devm_spi_alloc_host (&pdev->dev, +sizeof (struct fsl_lpspi_data ));if (!controller)return -ENOMEM ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 644/713 ASoC: rockchip: i2s-tdm: Fix inaccurate sampling rates
In reply to Sasha LevinFrom: Luca Ceresoli <[email protected]>
[ Upstream commit 9e2ab4b18ebd46813fc3459207335af4d368e323 ]
The sample rates set by the rockchip_i2s_tdm driver in master mode are inaccurate up to 5% in several cases, due to the driver logic to configure clocks and a nasty interaction with the Common Clock Framework.
To understand what happens, here is the relevant section of the clock tree (slightly simplified), along with the names used in the driver:
vpll0 _OR_ vpll1 "mclk_root"
clk_i2s2_8ch_tx_src "mclk_parent"
clk_i2s2_8ch_tx_mux
clk_i2s2_8ch_tx "mclk" or "mclk_tx"This is what happens when playing back e.g. at 192 kHz using audio-graph-card (when recording the same applies, only s/tx/rx/):
0. at probe, rockchip_i2s_tdm_set_sysclk() stores the passed frequency in
i2s_tdm->mclk_tx_freq (*) which is 50176000, and that is never modified
afterwards 1. when playback is started, rockchip_i2s_tdm_hw_params() is called and does the following two calls
2. rockchip_i2s_tdm_calibrate_mclk():
2a. selects mclk_root0 (vpll0) as a parent for mclk_parent
(mclk_tx_src), which is OK because the vpll0 rate is a good for 192000 (and sumbultiple) rates
2b. sets the mclk_root frequency based on ppm calibration computations
2c. sets mclk_tx_src to 49152000 (= 256 * 192000), which is also OK as
it is a multiple of the required bit clock
3. rockchip_i2s_tdm_set_mclk()
3a. calls clk_set_rate() to set the rate of mclk_tx (clk_i2s2_8ch_tx)
to the value of i2s_tdm->mclk_tx_freq (*), i.e. 50176000 which is not a multiple of the sampling frequency -- this is not OK
3a1. clk_set_rate() reacts by reparenting clk_i2s2_8ch_tx_src to
vpll1 -- this is not OK because the default vpll1 rate can be divided to get 44.1 kHz and related rates, not 192 kHz
The result is that the driver does a lot of ad-hoc decisions about clocks and ends up in using the wrong parent at an unoptimal rate.
Step 0 is one part of the problem: unless the card driver calls set_sysclk at each stream start, whatever rate is set in mclk_tx_freq during boot will be taken and used until reboot. Moreover the driver does not care if its value is not a multiple of any audio frequency.
Another part of the problem is that the whole reparenting and clock rate setting logic is conflicting with the CCF algorithms to achieve largely the same goal: selecting the best parent and setting the closest clock rate. And it turns out that only calling once clk_set_rate() on clk_i2s2_8ch_tx picks the correct vpll and sets the correct rate.
The fix is based on removing the custom logic in the driver to select the parent and set the various clocks, and just let the Clock Framework do it all. As a side effect, the set_sysclk() op becomes useless because we now let the CCF compute the appropriate value for the sampling rate. It also implies that the whole calibration logic is now dead code and so it is removed along with the "PCM Clock Compensation in PPM" kcontrol, which has always been broken anyway. The handling of the 4 optional clocks also becomes dead code and is removed.
The actual rates have been tested playing 30 seconds of audio at various sampling rates before and after this change using sox:
time play -r <sample_rate> -n synth 30 sine 950 gain -3
The time reported in the table below is the 'real' value reported by the 'time' command in the above command line.
rate before after
--------- ------ ------
8000 Hz 30.60s 30.63s
11025 Hz 30.45s 30.51s
16000 Hz 30.47s 30.50s
22050 Hz 30.78s 30.41s
32000 Hz 31.02s 30.43s
44100 Hz 30.78s 30.41s
48000 Hz 29.81s 30.45s
88200 Hz 30.78s 30.41s
96000 Hz 29.79s 30.42s
176400 Hz 27.40s 30.41s
192000 Hz 29.79s 30.42sWhile the tests are running the clock tree confirms that:
* without the patch, vpll1 is always used and clk_i2s2_8ch_tx always produces 50176000 Hz, which cannot be divided for most audio rates except the slowest ones, generating inaccurate rates
* with the patch:
- for 192000 Hz vpll0 is used
- for 176400 Hz vpll1 is used
- clk_i2s2_8ch_tx always produces (256 * <rate>) Hz
Tested on the RK3308 using the internal audio codec.
--- sound/soc/rockchip/rockchip_i2s_tdm.c | 352 +------------------------- 1 file changed, 6 insertions(+), 346 deletions(-)
sound/soc/rockchip/rockchip_i2s_tdm.c +6 -346
@@ -25,8 +25,6 @@#define DEFAULT_MCLK_FS 256#define CH_GRP_MAX 4/* The max channel 8 / 2 */ #define MULTIPLEX_CH_MAX 10 -#define CLK_PPM_MIN -1000 -#define CLK_PPM_MAX 1000#define TRCM_TXRX 0#define TRCM_TX 1
@@ -53,20 +51,6 @@ struct rk_i2s_tdm_dev {struct clk *hclk;struct clk *mclk_tx;struct clk *mclk_rx; -/* The mclk_tx_src is parent of mclk_tx */ -struct clk *mclk_tx_src; -/* The mclk_rx_src is parent of mclk_rx */ -struct clk *mclk_rx_src; -/* -* The mclk_root0 and mclk_root1 are root parent and supplies for -* the different FS. -* -* e.g: -* mclk_root0 is VPLL0, used for FS=48000Hz -* mclk_root1 is VPLL1, used for FS=44100Hz -*/ -struct clk *mclk_root0; -struct clk *mclk_root1;struct regmap *regmap;struct regmap *grf;struct snd_dmaengine_dai_dma_data capture_dma_data;
@@ -76,19 +60,11 @@ struct rk_i2s_tdm_dev {const struct rk_i2s_soc_data *soc_data;bool is_master_mode;bool io_multiplex; -bool mclk_calibrate;bool tdm_mode; -unsigned int mclk_rx_freq; -unsigned int mclk_tx_freq; -unsigned int mclk_root0_freq; -unsigned int mclk_root1_freq; -unsigned int mclk_root0_initial_freq; -unsigned int mclk_root1_initial_freq;unsigned int frame_width;unsigned int clk_trcm;unsigned int i2s_sdis[CH_GRP_MAX ];unsigned int i2s_sdos[CH_GRP_MAX ]; -int clk_ppm;int refcount;spinlock_t lock;/* xfer lock */ bool has_playback;
@@ -114,12 +90,6 @@ static void i2s_tdm_disable_unprepare_mclk(struct rk_i2s_tdm_dev *i2s_tdm) {clk_disable_unprepare (i2s_tdm->mclk_tx);clk_disable_unprepare (i2s_tdm->mclk_rx); -if (i2s_tdm->mclk_calibrate) { -clk_disable_unprepare (i2s_tdm->mclk_tx_src); -clk_disable_unprepare (i2s_tdm->mclk_rx_src); -clk_disable_unprepare (i2s_tdm->mclk_root0); -clk_disable_unprepare (i2s_tdm->mclk_root1); - } }/**
@@ -142,29 +112,9 @@ static int i2s_tdm_prepare_enable_mclk(struct rk_i2s_tdm_dev *i2s_tdm) ret =clk_prepare_enable (i2s_tdm->mclk_rx);if (ret) goto err_mclk_rx; -if (i2s_tdm->mclk_calibrate) { - ret =clk_prepare_enable (i2s_tdm->mclk_tx_src); -if (ret) - goto err_mclk_rx; - ret =clk_prepare_enable (i2s_tdm->mclk_rx_src); -if (ret) - goto err_mclk_rx_src; - ret =clk_prepare_enable (i2s_tdm->mclk_root0); -if (ret) - goto err_mclk_root0; - ret =clk_prepare_enable (i2s_tdm->mclk_root1); -if (ret) - goto err_mclk_root1; - }return 0 ; -err_mclk_root1: -clk_disable_unprepare (i2s_tdm->mclk_root0); -err_mclk_root0: -clk_disable_unprepare (i2s_tdm->mclk_rx_src); -err_mclk_rx_src: -clk_disable_unprepare (i2s_tdm->mclk_tx_src); err_mclk_rx:clk_disable_unprepare (i2s_tdm->mclk_tx); err_mclk_tx:
@@ -564,159 +514,6 @@ static void rockchip_i2s_tdm_xfer_resume(struct snd_pcm_substream *substream, I2S_XFER_RXS_START); } -static int rockchip_i2s_tdm_clk_set_rate (struct rk_i2s_tdm_dev *i2s_tdm, -struct clk *clk,unsigned long rate, -int ppm) -{ -unsigned long rate_target; -int delta, ret; - -if (ppm == i2s_tdm->clk_ppm) -return 0 ; - -if (ppm <0 ) - delta =-1 ; -else - delta =1 ; - - delta *= (int )div64_u64 ((u64 )rate * (u64 )abs (ppm) +500000 , -1000000 ); - - rate_target = rate + delta; - -if (!rate_target) -return -EINVAL ; - - ret =clk_set_rate (clk, rate_target); -if (ret) -return ret; - - i2s_tdm->clk_ppm = ppm; - -return 0 ; -} - -static int rockchip_i2s_tdm_calibrate_mclk (struct rk_i2s_tdm_dev *i2s_tdm, -struct snd_pcm_substream *substream, -unsigned int lrck_freq) -{ -struct clk *mclk_root; -struct clk *mclk_parent; -unsigned int mclk_root_freq; -unsigned int mclk_root_initial_freq; -unsigned int mclk_parent_freq; -unsigned int div, delta; -u64 ppm; -int ret; - -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) - mclk_parent = i2s_tdm->mclk_tx_src; -else - mclk_parent = i2s_tdm->mclk_rx_src; - -switch (lrck_freq) { -case 8000 : -case 16000 : -case 24000 : -case 32000 : -case 48000 : -case 64000 : -case 96000 : -case 192000 : - mclk_root = i2s_tdm->mclk_root0; - mclk_root_freq = i2s_tdm->mclk_root0_freq; - mclk_root_initial_freq = i2s_tdm->mclk_root0_initial_freq; - mclk_parent_freq =DEFAULT_MCLK_FS *192000 ; -break ; -case 11025 : -case 22050 : -case 44100 : -case 88200 : -case 176400 : - mclk_root = i2s_tdm->mclk_root1; - mclk_root_freq = i2s_tdm->mclk_root1_freq; - mclk_root_initial_freq = i2s_tdm->mclk_root1_initial_freq; - mclk_parent_freq =DEFAULT_MCLK_FS *176400 ; -break ; -default : -dev_err (i2s_tdm->dev,"Invalid LRCK frequency: %u Hz\n" , - lrck_freq); -return -EINVAL ; - } - - ret =clk_set_parent (mclk_parent, mclk_root); -if (ret) -return ret; - - ret =rockchip_i2s_tdm_clk_set_rate (i2s_tdm, mclk_root, - mclk_root_freq,0 ); -if (ret) -return ret; - - delta =abs (mclk_root_freq % mclk_parent_freq - mclk_parent_freq); - ppm =div64_u64 ((uint64_t )delta *1000000 , (uint64_t )mclk_root_freq); - -if (ppm) { - div =DIV_ROUND_CLOSEST (mclk_root_initial_freq, mclk_parent_freq); -if (!div) -return -EINVAL ; - - mclk_root_freq = mclk_parent_freq *round_up (div,2 ); - - ret =clk_set_rate (mclk_root, mclk_root_freq); -if (ret) -return ret; - - i2s_tdm->mclk_root0_freq =clk_get_rate (i2s_tdm->mclk_root0); - i2s_tdm->mclk_root1_freq =clk_get_rate (i2s_tdm->mclk_root1); - } - -return clk_set_rate (mclk_parent, mclk_parent_freq); -} - -static int rockchip_i2s_tdm_set_mclk (struct rk_i2s_tdm_dev *i2s_tdm, -struct snd_pcm_substream *substream, -struct clk **mclk) -{ -unsigned int mclk_freq; -int ret; - -if (i2s_tdm->clk_trcm) { -if (i2s_tdm->mclk_tx_freq != i2s_tdm->mclk_rx_freq) { -dev_err (i2s_tdm->dev, -"clk_trcm, tx: %d and rx: %d should be the same\n" , - i2s_tdm->mclk_tx_freq, - i2s_tdm->mclk_rx_freq); -return -EINVAL ; - } - - ret =clk_set_rate (i2s_tdm->mclk_tx, i2s_tdm->mclk_tx_freq); -if (ret) -return ret; - - ret =clk_set_rate (i2s_tdm->mclk_rx, i2s_tdm->mclk_rx_freq); -if (ret) -return ret; - -/* mclk_rx is also ok. */ - *mclk = i2s_tdm->mclk_tx; - }else { -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { - *mclk = i2s_tdm->mclk_tx; - mclk_freq = i2s_tdm->mclk_tx_freq; - }else { - *mclk = i2s_tdm->mclk_rx; - mclk_freq = i2s_tdm->mclk_rx_freq; - } - - ret =clk_set_rate (*mclk, mclk_freq); -if (ret) -return ret; - } - -return 0 ; -} -static int rockchip_i2s_ch_to_io (unsigned int ch,bool substream_capture) {if (substream_capture) {
@@ -853,19 +650,17 @@ static int rockchip_i2s_tdm_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) {struct rk_i2s_tdm_dev *i2s_tdm =to_info (dai); -struct clk *mclk; -int ret =0 ;unsigned int val =0 ;unsigned int mclk_rate, bclk_rate, div_bclk =4 , div_lrck =64 ; +int err;if (i2s_tdm->is_master_mode) { -if (i2s_tdm->mclk_calibrate) -rockchip_i2s_tdm_calibrate_mclk (i2s_tdm, substream, -params_rate (params)); +struct clk *mclk = (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) ? + i2s_tdm->mclk_tx : i2s_tdm->mclk_rx; - ret =rockchip_i2s_tdm_set_mclk (i2s_tdm, substream, &mclk); -if (ret) -return ret; + err =clk_set_rate (mclk,DEFAULT_MCLK_FS *params_rate (params)); +if (err) +return err; mclk_rate =clk_get_rate (mclk); bclk_rate = i2s_tdm->frame_width *params_rate (params);
@@ -973,96 +768,6 @@ static int rockchip_i2s_tdm_trigger(struct snd_pcm_substream *substream,return 0 ; } -static int rockchip_i2s_tdm_set_sysclk (struct snd_soc_dai *cpu_dai,int stream, -unsigned int freq,int dir) -{ -struct rk_i2s_tdm_dev *i2s_tdm =to_info (cpu_dai); - -/* Put set mclk rate into rockchip_i2s_tdm_set_mclk() */ -if (i2s_tdm->clk_trcm) { - i2s_tdm->mclk_tx_freq = freq; - i2s_tdm->mclk_rx_freq = freq; - }else { -if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) - i2s_tdm->mclk_tx_freq = freq; -else - i2s_tdm->mclk_rx_freq = freq; - } - -dev_dbg (i2s_tdm->dev,"The target mclk_%s freq is: %d\n" , - stream ?"rx" :"tx" , freq); - -return 0 ; -} - -static int rockchip_i2s_tdm_clk_compensation_info (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_info *uinfo) -{ - uinfo->type =SNDRV_CTL_ELEM_TYPE_INTEGER ; - uinfo->count =1 ; - uinfo->value.integer.min =CLK_PPM_MIN ; - uinfo->value.integer.max =CLK_PPM_MAX ; - uinfo->value.integer.step =1 ; - -return 0 ; -} - -static int rockchip_i2s_tdm_clk_compensation_get (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_value *ucontrol) -{ -struct snd_soc_dai *dai =snd_kcontrol_chip (kcontrol); -struct rk_i2s_tdm_dev *i2s_tdm =snd_soc_dai_get_drvdata (dai); - - ucontrol->value.integer.value[0 ] = i2s_tdm->clk_ppm; - -return 0 ; -} - -static int rockchip_i2s_tdm_clk_compensation_put (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_value *ucontrol) -{ -struct snd_soc_dai *dai =snd_kcontrol_chip (kcontrol); -struct rk_i2s_tdm_dev *i2s_tdm =snd_soc_dai_get_drvdata (dai); -int ret =0 , ppm =0 ; -int changed =0 ; -unsigned long old_rate; - -if (ucontrol->value.integer.value[0 ] <CLK_PPM_MIN || - ucontrol->value.integer.value[0 ] >CLK_PPM_MAX ) -return -EINVAL ; - - ppm = ucontrol->value.integer.value[0 ]; - - old_rate =clk_get_rate (i2s_tdm->mclk_root0); - ret =rockchip_i2s_tdm_clk_set_rate (i2s_tdm, i2s_tdm->mclk_root0, - i2s_tdm->mclk_root0_freq, ppm); -if (ret) -return ret; -if (old_rate !=clk_get_rate (i2s_tdm->mclk_root0)) - changed =1 ; - -if (clk_is_match (i2s_tdm->mclk_root0, i2s_tdm->mclk_root1)) -return changed; - - old_rate =clk_get_rate (i2s_tdm->mclk_root1); - ret =rockchip_i2s_tdm_clk_set_rate (i2s_tdm, i2s_tdm->mclk_root1, - i2s_tdm->mclk_root1_freq, ppm); -if (ret) -return ret; -if (old_rate !=clk_get_rate (i2s_tdm->mclk_root1)) - changed =1 ; - -return changed; -} - -static struct snd_kcontrol_new rockchip_i2s_tdm_compensation_control = { - .iface =SNDRV_CTL_ELEM_IFACE_PCM , - .name ="PCM Clock Compensation in PPM" , - .info = rockchip_i2s_tdm_clk_compensation_info, - .get = rockchip_i2s_tdm_clk_compensation_get, - .put = rockchip_i2s_tdm_clk_compensation_put, -}; -static int rockchip_i2s_tdm_dai_probe (struct snd_soc_dai *dai) {struct rk_i2s_tdm_dev *i2s_tdm =snd_soc_dai_get_drvdata (dai);
@@ -1072,9 +777,6 @@ static int rockchip_i2s_tdm_dai_probe(struct snd_soc_dai *dai)if (i2s_tdm->has_playback)snd_soc_dai_dma_data_set_playback (dai, &i2s_tdm->playback_dma_data); -if (i2s_tdm->mclk_calibrate) -snd_soc_add_dai_controls (dai, &rockchip_i2s_tdm_compensation_control,1 ); -return 0 ; }
@@ -1115,7 +817,6 @@ static const struct snd_soc_dai_ops rockchip_i2s_tdm_dai_ops = { .probe = rockchip_i2s_tdm_dai_probe, .hw_params = rockchip_i2s_tdm_hw_params, .set_bclk_ratio = rockchip_i2s_tdm_set_bclk_ratio, - .set_sysclk = rockchip_i2s_tdm_set_sysclk, .set_fmt = rockchip_i2s_tdm_set_fmt, .set_tdm_slot = rockchip_dai_tdm_slot, .trigger = rockchip_i2s_tdm_trigger,
@@ -1444,35 +1145,6 @@ static void rockchip_i2s_tdm_path_config(struct rk_i2s_tdm_dev *i2s_tdm,rockchip_i2s_tdm_tx_path_config (i2s_tdm, num); } -static int rockchip_i2s_tdm_get_calibrate_mclks (struct rk_i2s_tdm_dev *i2s_tdm) -{ -int num_mclks =0 ; - - i2s_tdm->mclk_tx_src =devm_clk_get (i2s_tdm->dev,"mclk_tx_src" ); -if (!IS_ERR (i2s_tdm->mclk_tx_src)) - num_mclks++; - - i2s_tdm->mclk_rx_src =devm_clk_get (i2s_tdm->dev,"mclk_rx_src" ); -if (!IS_ERR (i2s_tdm->mclk_rx_src)) - num_mclks++; - - i2s_tdm->mclk_root0 =devm_clk_get (i2s_tdm->dev,"mclk_root0" ); -if (!IS_ERR (i2s_tdm->mclk_root0)) - num_mclks++; - - i2s_tdm->mclk_root1 =devm_clk_get (i2s_tdm->dev,"mclk_root1" ); -if (!IS_ERR (i2s_tdm->mclk_root1)) - num_mclks++; - -if (num_mclks <4 && num_mclks !=0 ) -return -ENOENT ; - -if (num_mclks ==4 ) - i2s_tdm->mclk_calibrate =1 ; - -return 0 ; -} -static int rockchip_i2s_tdm_path_prepare (struct rk_i2s_tdm_dev *i2s_tdm,struct device_node *np,bool is_rx_path)
@@ -1610,11 +1282,6 @@ static int rockchip_i2s_tdm_probe(struct platform_device *pdev) i2s_tdm->io_multiplex =of_property_read_bool (node,"rockchip,io-multiplex" ); - ret =rockchip_i2s_tdm_get_calibrate_mclks (i2s_tdm); -if (ret) -return dev_err_probe (i2s_tdm->dev, ret, -"mclk-calibrate clocks missing" ); - regs =devm_platform_get_and_ioremap_resource (pdev,0 , &res);if (IS_ERR (regs)) { return dev_err_probe(i2s_tdm->dev, PTR_ERR(regs),
@@ -1667,13 +1334,6 @@ static int rockchip_i2s_tdm_probe(struct platform_device *pdev) goto err_disable_hclk; } -if (i2s_tdm->mclk_calibrate) { - i2s_tdm->mclk_root0_initial_freq =clk_get_rate (i2s_tdm->mclk_root0); - i2s_tdm->mclk_root1_initial_freq =clk_get_rate (i2s_tdm->mclk_root1); - i2s_tdm->mclk_root0_freq = i2s_tdm->mclk_root0_initial_freq; - i2s_tdm->mclk_root1_freq = i2s_tdm->mclk_root1_initial_freq; - } -pm_runtime_enable (&pdev->dev); regmap_update_bits(i2s_tdm->regmap, I2S_DMACR, I2S_DMACR_TDL_MASK,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 645/713 nouveau: reset the bo resource bus info after an eviction
In reply to Sasha LevinFrom: Dave Airlie <[email protected]>
[ Upstream commit f35c9af45ea7a4b1115b193d84858b14d13517fc ]
Later attempts to refault the bo won't happen and the whole GPU does to lunch. I think Christian's refactoring of this code out to the driver broke this not very well tested path.
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -0
@@ -1255,6 +1255,8 @@ nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)drm_vma_node_unmap (&nvbo->bo.base.vma_node, bdev->dev_mapping);nouveau_ttm_io_mem_free_locked (drm, nvbo->bo.resource); + nvbo->bo.resource->bus.offset =0 ; + nvbo->bo.resource->bus.addr =NULL ; goto retry; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 646/713 tcp: Fix NEW_SYN_RECV handling in inet_twsk_purge()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 1c4e97dd2d3c9a3e84f7e26346aa39bc426d3249 ]
inet_twsk_purge() uses rcu to find TIME_WAIT and NEW_SYN_RECV objects to purge.
These objects use SLAB_TYPESAFE_BY_RCU semantic and need special care. We need to use refcount_inc_not_zero(&sk->sk_refcnt).
Reuse the existing correct logic I wrote for TIME_WAIT, because both structures have common locations for sk_state, sk_family, and netns pointer.
If after the refcount_inc_not_zero() the object fields longer match the keys, use sock_gen_put(sk) to release the refcount.
Then we can call inet_twsk_deschedule_put() for TIME_WAIT, inet_csk_reqsk_queue_drop_and_put() for NEW_SYN_RECV sockets, with BH disabled.
Then we need to restart the loop because we had drop rcu_read_lock().
--- net/ipv4/inet_timewait_sock.c | 41 ++++++++++++++++------------------- 1 file changed, 19 insertions(+), 22 deletions(-)
net/ipv4/inet_timewait_sock.c +19 -22
@@ -278,12 +278,12 @@ void __inet_twsk_schedule(struct inet_timewait_sock *tw, int timeo, bool rearm) }EXPORT_SYMBOL_GPL (__inet_twsk_schedule); +/* Remove all non full sockets (TIME_WAIT and NEW_SYN_RECV) for dead netns */ void inet_twsk_purge (struct inet_hashinfo *hashinfo,int family) { -struct inet_timewait_sock *tw; -struct sock *sk;struct hlist_nulls_node *node;unsigned int slot; +struct sock *sk;for (slot =0 ; slot <= hashinfo->ehash_mask; slot++) {struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
@@ -292,38 +292,35 @@ void inet_twsk_purge(struct inet_hashinfo *hashinfo, int family)rcu_read_lock (); restart:sk_nulls_for_each_rcu (sk, node, &head->chain) { -if (sk->sk_state !=TCP_TIME_WAIT ) { -/* A kernel listener socket might not hold refcnt for net, -* so reqsk_timer_handler() could be fired after net is -* freed. Userspace listener and reqsk never exist here. -*/ -if (unlikely (sk->sk_state ==TCP_NEW_SYN_RECV && - hashinfo->pernet)) { -struct request_sock *req =inet_reqsk (sk); - -inet_csk_reqsk_queue_drop_and_put (req->rsk_listener, req); - } +int state =inet_sk_state_load (sk); +if ((1 << state) & ~(TCPF_TIME_WAIT | +TCPF_NEW_SYN_RECV ))continue ; - } - tw =inet_twsk (sk); -if ((tw->tw_family != family) || -refcount_read (&twsk_net (tw)->ns.count)) +if (sk->sk_family != family || +refcount_read (&sock_net (sk)->ns.count))continue ; -if (unlikely (!refcount_inc_not_zero (&tw->tw_refcnt))) +if (unlikely (!refcount_inc_not_zero (&sk->sk_refcnt)))continue ; -if (unlikely ((tw->tw_family != family) || -refcount_read (&twsk_net (tw)->ns.count))) { -inet_twsk_put (tw); +if (unlikely (sk->sk_family != family || +refcount_read (&sock_net (sk)->ns.count))) { +sock_gen_put (sk); goto restart; }rcu_read_unlock ();local_bh_disable (); -inet_twsk_deschedule_put (tw); +if (state ==TCP_TIME_WAIT ) { +inet_twsk_deschedule_put (inet_twsk (sk)); + }else { +struct request_sock *req =inet_reqsk (sk); + +inet_csk_reqsk_queue_drop_and_put (req->rsk_listener, + req); + }local_bh_enable (); goto restart_rcu; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 647/713 rds: tcp: Fix use-after-free of net in reqsk_timer_handler().
In reply to Sasha LevinFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 2a750d6a5b365265dbda33330a6188547ddb5c24 ]
syzkaller reported a warning of netns tracker [0] followed by KASAN splat [1] and another ref tracker warning [1].
syzkaller could not find a repro, but in the log, the only suspicious sequence was as follows:
18:26:22 executing program 1:
r0 = socket$inet6_mptcp(0xa, 0x1, 0x106)
...
connect$inet6(r0, &(0x7f0000000080)={0xa, 0x4001, 0x0, @loopback}, 0x1c) (async)
The notable thing here is 0x4001 in connect(), which is RDS_TCP_PORT.
So, the scenario would be:
1. unshare(CLONE_NEWNET) creates a per netns tcp listener in
rds_tcp_listen_init().
2. syz-executor connect()s to it and creates a reqsk.
3. syz-executor exit()s immediately.
4. netns is dismantled. [0]
5. reqsk timer is fired, and UAF happens while freeing reqsk. [1]
6. listener is freed after RCU grace period. [2]
Basically, reqsk assumes that the listener guarantees netns safety until all reqsk timers are expired by holding the listener's refcount. However, this was not the case for kernel sockets.
Commit 740ea3c4a0b2 ("tcp: Clean up kernel listener's reqsk in inet_twsk_purge()") fixed this issue only for per-netns ehash.
Let's apply the same fix for the global ehash.
[0]:ref_tracker: net notrefcnt@0000000065449cc3 has 1/1 users at
sk_alloc (./include/net/net_namespace.h:337 net/core/sock.c:2146)
inet6_create (net/ipv6/af_inet6.c:192 net/ipv6/af_inet6.c:119)
__sock_create (net/socket.c:1572)
rds_tcp_listen_init (net/rds/tcp_listen.c:279)
rds_tcp_init_net (net/rds/tcp.c:577)
ops_init (net/core/net_namespace.c:137)
setup_net (net/core/net_namespace.c:340)
copy_net_ns (net/core/net_namespace.c:497)
create_new_namespaces (kernel/nsproxy.c:110)
unshare_nsproxy_namespaces (kernel/nsproxy.c:228 (discriminator 4))
ksys_unshare (kernel/fork.c:3429)
__x64_sys_unshare (kernel/fork.c:3496)
do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83)
entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:129)
...
WARNING: CPU: 0 PID: 27 at lib/ref_tracker.c:179 ref_tracker_dir_exit (lib/ref_tracker.c:179)[1]:
BUG: KASAN: slab-use-after-free in inet_csk_reqsk_queue_drop (./include/net/inet_hashtables.h:180 net/ipv4/inet_connection_sock.c:952 net/ipv4/inet_connection_sock.c:966) Read of size 8 at addr ffff88801b370400 by task swapper/0/0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 Call Trace: <IRQ> dump_stack_lvl (lib/dump_stack.c:107 (discriminator 1)) print_report (mm/kasan/report.c:378 mm/kasan/report.c:488) kasan_report (mm/kasan/report.c:603) inet_csk_reqsk_queue_drop (./include/net/inet_hashtables.h:180 net/ipv4/inet_connection_sock.c:952 net/ipv4/inet_connection_sock.c:966) reqsk_timer_handler (net/ipv4/inet_connection_sock.c:979 net/ipv4/inet_connection_sock.c:1092) call_timer_fn (./arch/x86/include/asm/jump_label.h:27 ./include/linux/jump_label.h:207 ./include/trace/events/timer.h:127 kernel/time/timer.c:1701) __run_timers.part.0 (kernel/time/timer.c:1752 kernel/time/timer.c:2038) run_timer_softirq (kernel/time/timer.c:2053) __do_softirq (./arch/x86/include/asm/jump_label.h:27 ./include/linux/jump_label.h:207 ./include/trace/events/irq.h:142 kernel/softirq.c:554) irq_exit_rcu (kernel/softirq.c:427 kernel/softirq.c:632 kernel/softirq.c:644) sysvec_apic_timer_interrupt (arch/x86/kernel/apic/apic.c:1076 (discriminator 14)) </IRQ> Allocated by task 258 on cpu 0 at 83.612050s: kasan_save_stack (mm/kasan/common.c:48) kasan_save_track (mm/kasan/common.c:68) __kasan_slab_alloc (mm/kasan/common.c:343) kmem_cache_alloc (mm/slub.c:3813 mm/slub.c:3860 mm/slub.c:3867) copy_net_ns (./include/linux/slab.h:701 net/core/net_namespace.c:421 net/core/net_namespace.c:480) create_new_namespaces (kernel/nsproxy.c:110) unshare_nsproxy_namespaces (kernel/nsproxy.c:228 (discriminator 4)) ksys_unshare (kernel/fork.c:3429) __x64_sys_unshare (kernel/fork.c:3496) do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:129) Freed by task 27 on cpu 0 at 329.158864s: kasan_save_stack (mm/kasan/common.c:48) kasan_save_track (mm/kasan/common.c:68) kasan_save_free_info (mm/kasan/generic.c:643) __kasan_slab_free (mm/kasan/common.c:265) kmem_cache_free (mm/slub.c:4299 mm/slub.c:4363) cleanup_net (net/core/net_namespace.c:456 net/core/net_namespace.c:446 net/core/net_namespace.c:639) process_one_work (kernel/workqueue.c:2638) worker_thread (kernel/workqueue.c:2700 kernel/workqueue.c:2787) kthread (kernel/kthread.c:388) ret_from_fork (arch/x86/kernel/process.c:153) ret_from_fork_asm (arch/x86/entry/entry_64.S:250) The buggy address belongs to the object at ffff88801b370000 which belongs to the cache net_namespace of size 4352
The buggy address is located 1024 bytes inside of
freed 4352-byte region [ffff88801b370000, ffff88801b371100)
[2]:
WARNING: CPU: 0 PID: 95 at lib/ref_tracker.c:228 ref_tracker_free (lib/ref_tracker.c:228 (discriminator 1)) Modules linked in: Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 RIP: 0010:ref_tracker_free (lib/ref_tracker.c:228 (discriminator 1)) ... Call Trace: <IRQ> __sk_destruct (./include/net/net_namespace.h:353 net/core/sock.c:2204) rcu_core (./arch/x86/include/asm/preempt.h:26 kernel/rcu/tree.c:2165 kernel/rcu/tree.c:2433) __do_softirq (./arch/x86/include/asm/jump_label.h:27 ./include/linux/jump_label.h:207 ./include/trace/events/irq.h:142 kernel/softirq.c:554) irq_exit_rcu (kernel/softirq.c:427 kernel/softirq.c:632 kernel/softirq.c:644) sysvec_apic_timer_interrupt (arch/x86/kernel/apic/apic.c:1076 (discriminator 14)) </IRQ>
--- net/ipv4/tcp_minisocks.c | 4 ---- 1 file changed, 4 deletions(-)
net/ipv4/tcp_minisocks.c +0 -4
@@ -398,10 +398,6 @@ void tcp_twsk_purge(struct list_head *net_exit_list, int family)/* Even if tw_refcount == 1, we must clean up kernel reqsk */ inet_twsk_purge (net->ipv4.tcp_death_row.hashinfo, family); }else if (!purged_once) { -/* The last refcount is decremented in tcp_sk_exit_batch() */ -if (refcount_read (&net->ipv4.tcp_death_row.tw_refcount) ==1 ) -continue ; -inet_twsk_purge (&tcp_hashinfo, family); purged_once = true; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 648/713 octeontx2-af: Use matching wake_up API variant in CGX command interface
In reply to Sasha LevinFrom: Linu Cherian <[email protected]>
[ Upstream commit e642921dfeed1e15e73f78f2c3b6746f72b6deb2 ]
Use wake_up API instead of wake_up_interruptible, since wait_event_timeout API is used for waiting on command completion.
--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +1 -1
@@ -1338,7 +1338,7 @@ static irqreturn_t cgx_fwi_event_handler(int irq, void *data)/* Release thread waiting for completion */ lmac->cmd_pend = false; -wake_up_interruptible (&lmac->wq_cmd_cmplt); +wake_up (&lmac->wq_cmd_cmplt);break ;case CGX_EVT_ASYNC :if (cgx_event_is_linkevent (event))
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 649/713 s390/vtime: fix average steal time calculation
In reply to Sasha LevinFrom: Mete Durlu <[email protected]>
[ Upstream commit 367c50f78451d3bd7ad70bc5c89f9ba6dec46ca9 ]
Current average steal timer calculation produces volatile and inflated values. The only user of this value is KVM so far and it uses that to decide whether or not to yield the vCPU which is seeing steal time. KVM compares average steal timer to a threshold and if the threshold is past then it does not allow CPU polling and yields it to host, else it keeps the CPU by polling.
Since KVM's steal time threshold is very low by default (%10) it most likely is not effected much by the bloated average steal timer values because the operating region is pretty small. However there might be new users in the future who might rely on this number. Fix average steal timer calculation by changing the formula from:
avg_steal_timer = avg_steal_timer / 2 + steal_timer;
to the following:
avg_steal_timer = (avg_steal_timer + steal_timer) / 2;
This ensures that avg_steal_timer is actually a naive average of steal timer values. It now closely follows steal timer values but of course in a smoother manner.
--- arch/s390/kernel/vtime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/kernel/vtime.c +2 -2
@@ -210,13 +210,13 @@ void vtime_flush(struct task_struct *tsk)virt_timer_expire (); steal = S390_lowcore.steal_timer; - avg_steal = S390_lowcore.avg_steal_timer /2 ; + avg_steal = S390_lowcore.avg_steal_timer;if ((s64 ) steal >0 ) { S390_lowcore.steal_timer =0 ;account_steal_time (cputime_to_nsecs (steal)); avg_steal += steal; } - S390_lowcore.avg_steal_timer = avg_steal; + S390_lowcore.avg_steal_timer = avg_steal /2 ; }static u64 vtime_delta (void )
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 650/713 net/sched: taprio: proper TCA_TAPRIO_TC_ENTRY_INDEX check
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 343041b59b7810f9cdca371f445dd43b35c740b1 ]
taprio_parse_tc_entry() is not correctly checkingTCA_TAPRIO_TC_ENTRY_INDEX attribute:
int tc; // Signed value
tc = nla_get_u32(tb[TCA_TAPRIO_TC_ENTRY_INDEX]);
if (tc >= TC_QOPT_MAX_QUEUE) {
NL_SET_ERR_MSG_MOD(extack, "TC entry index out of range");
return -ERANGE;
}syzbot reported that it could fed arbitary negative values:
UBSAN: shift-out-of-bounds in net/sched/sch_taprio.c:1722:18 shift exponent -2147418108 is negative CPU: 0 PID: 5066 Comm: syz-executor367 Not tainted 6.8.0-rc7-syzkaller-00136-gc8a5c731fd12 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/29/2024 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e7/0x2e0 lib/dump_stack.c:106 ubsan_epilogue lib/ubsan.c:217 [inline] __ubsan_handle_shift_out_of_bounds+0x3c7/0x420 lib/ubsan.c:386 taprio_parse_tc_entry net/sched/sch_taprio.c:1722 [inline] taprio_parse_tc_entries net/sched/sch_taprio.c:1768 [inline] taprio_change+0xb87/0x57d0 net/sched/sch_taprio.c:1877 taprio_init+0x9da/0xc80 net/sched/sch_taprio.c:2134 qdisc_create+0x9d4/0x1190 net/sched/sch_api.c:1355 tc_modify_qdisc+0xa26/0x1e40 net/sched/sch_api.c:1776 rtnetlink_rcv_msg+0x885/0x1040 net/core/rtnetlink.c:6617 netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2543 netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline] netlink_unicast+0x7ea/0x980 net/netlink/af_netlink.c:1367 netlink_sendmsg+0xa3b/0xd70 net/netlink/af_netlink.c:1908 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x221/0x270 net/socket.c:745 ____sys_sendmsg+0x525/0x7d0 net/socket.c:2584 ___sys_sendmsg net/socket.c:2638 [inline] __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667 do_syscall_64+0xf9/0x240 entry_SYSCALL_64_after_hwframe+0x6f/0x77 RIP: 0033:0x7f1b2dea3759 Code: 48 83 c4 28 c3 e8 d7 19 00 00 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffd4de452f8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f1b2def0390 RCX: 00007f1b2dea3759 RDX: 0000000000000000 RSI: 00000000200007c0 RDI: 0000000000000004 RBP: 0000000000000003 R08: 0000555500000000 R09: 0000555500000000 R10: 0000555500000000 R11: 0000000000000246 R12: 00007ffd4de45340 R13: 00007ffd4de45310 R14: 0000000000000001 R15: 00007ffd4de45340
--- net/sched/sch_taprio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sched/sch_taprio.c +2 -1
@@ -1008,7 +1008,8 @@ static const struct nla_policy entry_policy[TCA_TAPRIO_SCHED_ENTRY_MAX + 1] = { };static const struct nla_policy taprio_tc_policy[TCA_TAPRIO_TC_ENTRY_MAX +1 ] = { - [TCA_TAPRIO_TC_ENTRY_INDEX ] = { .type =NLA_U32 }, + [TCA_TAPRIO_TC_ENTRY_INDEX ] =NLA_POLICY_MAX (NLA_U32 , +TC_QOPT_MAX_QUEUE ), [TCA_TAPRIO_TC_ENTRY_MAX_SDU ] = { .type =NLA_U32 }, [TCA_TAPRIO_TC_ENTRY_FP] = NLA_POLICY_RANGE(NLA_U32, TC_FP_EXPRESS,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 651/713 devlink: Move private netlink flags to C file
In reply to Sasha LevinFrom: Ido Schimmel <[email protected]>
[ Upstream commit 526dd6d7877b80b1f56d87156b65b8227c69d59f ]
The flags are not used outside of the C file so move them there.
Stable-dep-of: d7d75124965a ("devlink: Fix devlink parallel commands processing")
--- net/devlink/devl_internal.h | 3 --- net/devlink/netlink.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
net/devlink/devl_internal.h +0 -3
@@ -111,9 +111,6 @@ int devlink_rel_devlink_handle_put(struct sk_buff *msg, struct devlink *devlink, bool *msg_updated);/* Netlink */ -#define DEVLINK_NL_FLAG_NEED_PORT BIT(0) -#define DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT BIT(1) -enum devlink_multicast_groups {DEVLINK_MCGRP_CONFIG , };
net/devlink/netlink.c +3 -0
@@ -9,6 +9,9 @@#include "devl_internal.h" +#define DEVLINK_NL_FLAG_NEED_PORT BIT(0) +#define DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT BIT(1) +static const struct genl_multicast_group devlink_nl_mcgrps[] = { [DEVLINK_MCGRP_CONFIG ] = { .name =DEVLINK_GENL_MCGRP_CONFIG_NAME }, };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 652/713 devlink: Acquire device lock during netns dismantle
In reply to Sasha LevinFrom: Ido Schimmel <[email protected]>
[ Upstream commit e21c52d7814f5768f05224e773644629fe124af2 ]
Device drivers register with devlink from their probe routines (under the device lock) by acquiring the devlink instance lock and calling devl_register().
Drivers that support a devlink reload usually implement the reload_{down, up}() operations in a similar fashion to their remove and probe routines, respectively.
However, while the remove and probe routines are invoked with the device lock held, the reload operations are only invoked with the devlink instance lock held. It is therefore impossible for drivers to acquire the device lock from their reload operations, as this would result in lock inversion.
The motivating use case for invoking the reload operations with the device lock held is in mlxsw which needs to trigger a PCI reset as part of the reload. The driver cannot call pci_reset_function() as this function acquires the device lock. Instead, it needs to call __pci_reset_function_locked which expects the device lock to be held.
To that end, adjust devlink to always acquire the device lock before the devlink instance lock when performing a reload.
For now, only do that when reload is triggered as part of netns dismantle. Subsequent patches will handle the case where reload is explicitly triggered by user space.
Stable-dep-of: d7d75124965a ("devlink: Fix devlink parallel commands processing")
--- net/devlink/core.c | 4 ++-- net/devlink/devl_internal.h | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-)
net/devlink/core.c +2 -2
@@ -503,14 +503,14 @@ static void __net_exit devlink_pernet_pre_exit(struct net *net)* all devlink instances from this namespace into init_net. */ devlinks_xa_for_each_registered_get (net, index, devlink) { -devl_lock (devlink); +devl_dev_lock (devlink, true); err =0 ;if (devl_is_registered (devlink)) err =devlink_reload (devlink, &init_net,DEVLINK_RELOAD_ACTION_DRIVER_REINIT ,DEVLINK_RELOAD_LIMIT_UNSPEC , &actions_performed,NULL ); -devl_unlock (devlink); +devl_dev_unlock (devlink, true);devlink_put (devlink);if (err && err != -EOPNOTSUPP )pr_warn ("Failed to reload devlink instance into init_net\n" );
net/devlink/devl_internal.h +15 -0
@@ -3,6 +3,7 @@* Copyright (c) 2016 Jiri Pirko <[email protected]> */ +#include <linux/device.h> #include <linux/etherdevice.h> #include <linux/mutex.h> #include <linux/netdevice.h>
@@ -96,6 +97,20 @@ static inline bool devl_is_registered(struct devlink *devlink)return xa_get_mark (&devlinks, devlink->index,DEVLINK_REGISTERED ); } +static inline void devl_dev_lock (struct devlink *devlink,bool dev_lock) +{ +if (dev_lock) +device_lock (devlink->dev); +devl_lock (devlink); +} + +static inline void devl_dev_unlock (struct devlink *devlink,bool dev_lock) +{ +devl_unlock (devlink); +if (dev_lock) +device_unlock (devlink->dev); +} +typedef void devlink_rel_notify_cb_t (struct devlink *devlink,u32 obj_index);typedef void devlink_rel_cleanup_cb_t (struct devlink *devlink,u32 obj_index,u32 rel_index);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 653/713 devlink: Enable the use of private flags in post_doit operations
In reply to Sasha LevinFrom: Ido Schimmel <[email protected]>
[ Upstream commit c8d0a7d6152bec970552786b77626f4b4c562f4d ]
Currently, private flags (e.g., 'DEVLINK_NL_FLAG_NEED_PORT') are only used in pre_doit operations, but a subsequent patch will need to conditionally lock and unlock the device lock in pre and post doit operations, respectively.
As a preparation, enable the use of private flags in post_doit operations in a similar fashion to how it is done for pre_doit operations.
No functional changes intended.
Stable-dep-of: d7d75124965a ("devlink: Fix devlink parallel commands processing")
--- net/devlink/netlink.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/devlink/netlink.c +8 -2
@@ -141,8 +141,8 @@ int devlink_nl_pre_doit_port_optional(const struct genl_split_ops *ops,return __devlink_nl_pre_doit (skb, info,DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT ); } -void devlink_nl_post_doit (const struct genl_split_ops *ops, -struct sk_buff *skb,struct genl_info *info) +static void __devlink_nl_post_doit (struct sk_buff *skb,struct genl_info *info, +u8 flags) {struct devlink *devlink;
@@ -151,6 +151,12 @@ void devlink_nl_post_doit(const struct genl_split_ops *ops,devlink_put (devlink); } +void devlink_nl_post_doit (const struct genl_split_ops *ops, +struct sk_buff *skb,struct genl_info *info) +{ +__devlink_nl_post_doit (skb, info,0 ); +} + static int devlink_nl_inst_single_dumpit(struct sk_buff *msg, struct netlink_callback *cb, int flags, devlink_nl_dump_one_func_t *dump_one,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 654/713 devlink: Allow taking device lock in pre_doit operations
In reply to Sasha LevinFrom: Ido Schimmel <[email protected]>
[ Upstream commit d32c38256db30a2d55b849e2c77342bc70d58c6e ]
Introduce a new private flag ('DEVLINK_NL_FLAG_NEED_DEV_LOCK') to allow netlink commands to specify that they need to acquire the device lock in their pre_doit operation and release it in their post_doit operation.
The reload command will use this flag in the subsequent patch.
No functional changes intended.
Stable-dep-of: d7d75124965a ("devlink: Fix devlink parallel commands processing")
--- net/devlink/devl_internal.h | 3 ++- net/devlink/health.c | 3 ++- net/devlink/netlink.c | 19 ++++++++++++------- net/devlink/region.c | 3 ++- 4 files changed, 18 insertions(+), 10 deletions(-)
net/devlink/devl_internal.h +2 -1
@@ -152,7 +152,8 @@ typedef int devlink_nl_dump_one_func_t(struct sk_buff *msg, int flags);struct devlink * -devlink_get_from_attrs_lock (struct net *net,struct nlattr **attrs); +devlink_get_from_attrs_lock (struct net *net,struct nlattr **attrs, +bool dev_lock);int devlink_nl_dumpit (struct sk_buff *msg,struct netlink_callback *cb,devlink_nl_dump_one_func_t *dump_one);
net/devlink/health.c +2 -1
@@ -1151,7 +1151,8 @@ devlink_health_reporter_get_from_cb_lock(struct netlink_callback *cb)struct nlattr **attrs = info->attrs;struct devlink *devlink; - devlink =devlink_get_from_attrs_lock (sock_net (cb->skb->sk), attrs); + devlink =devlink_get_from_attrs_lock (sock_net (cb->skb->sk), attrs, + false);if (IS_ERR (devlink))return NULL ;
net/devlink/netlink.c +12 -7
@@ -11,6 +11,7 @@#define DEVLINK_NL_FLAG_NEED_PORT BIT(0)#define DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT BIT(1) +#define DEVLINK_NL_FLAG_NEED_DEV_LOCK BIT(2)static const struct genl_multicast_group devlink_nl_mcgrps[] = { [DEVLINK_MCGRP_CONFIG ] = { .name =DEVLINK_GENL_MCGRP_CONFIG_NAME },
@@ -64,7 +65,8 @@ int devlink_nl_msg_reply_and_new(struct sk_buff **msg, struct genl_info *info) }struct devlink * -devlink_get_from_attrs_lock (struct net *net,struct nlattr **attrs) +devlink_get_from_attrs_lock (struct net *net,struct nlattr **attrs, +bool dev_lock) {struct devlink *devlink;unsigned long index;
@@ -78,12 +80,12 @@ devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs) devname =nla_data (attrs[DEVLINK_ATTR_DEV_NAME ]);devlinks_xa_for_each_registered_get (net, index, devlink) { -devl_lock (devlink); +devl_dev_lock (devlink, dev_lock);if (devl_is_registered (devlink) &&strcmp (devlink->dev->bus->name, busname) ==0 &&strcmp (dev_name (devlink->dev), devname) ==0 )return devlink; -devl_unlock (devlink); +devl_dev_unlock (devlink, dev_lock);devlink_put (devlink); }
@@ -93,11 +95,13 @@ devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs)static int __devlink_nl_pre_doit (struct sk_buff *skb,struct genl_info *info,u8 flags) { +bool dev_lock = flags &DEVLINK_NL_FLAG_NEED_DEV_LOCK ;struct devlink_port *devlink_port;struct devlink *devlink;int err; - devlink =devlink_get_from_attrs_lock (genl_info_net (info), info->attrs); + devlink =devlink_get_from_attrs_lock (genl_info_net (info), info->attrs, + dev_lock);if (IS_ERR (devlink))return PTR_ERR (devlink);
@@ -117,7 +121,7 @@ static int __devlink_nl_pre_doit(struct sk_buff *skb, struct genl_info *info,return 0 ; unlock: -devl_unlock (devlink); +devl_dev_unlock (devlink, dev_lock);devlink_put (devlink);return err; }
@@ -144,10 +148,11 @@ int devlink_nl_pre_doit_port_optional(const struct genl_split_ops *ops,static void __devlink_nl_post_doit (struct sk_buff *skb,struct genl_info *info,u8 flags) { +bool dev_lock = flags &DEVLINK_NL_FLAG_NEED_DEV_LOCK ;struct devlink *devlink; devlink = info->user_ptr[0 ]; -devl_unlock (devlink); +devl_dev_unlock (devlink, dev_lock);devlink_put (devlink); }
@@ -165,7 +170,7 @@ static int devlink_nl_inst_single_dumpit(struct sk_buff *msg,struct devlink *devlink;int err; - devlink =devlink_get_from_attrs_lock (sock_net (msg->sk), attrs); + devlink =devlink_get_from_attrs_lock (sock_net (msg->sk), attrs, false);if (IS_ERR (devlink))return PTR_ERR (devlink); err =dump_one (msg, devlink, cb, flags |NLM_F_DUMP_FILTERED );
net/devlink/region.c +2 -1
@@ -883,7 +883,8 @@ int devlink_nl_region_read_dumpit(struct sk_buff *skb, start_offset = state->start_offset; - devlink =devlink_get_from_attrs_lock (sock_net (cb->skb->sk), attrs); + devlink =devlink_get_from_attrs_lock (sock_net (cb->skb->sk), attrs, + false);if (IS_ERR (devlink))return PTR_ERR (devlink);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 655/713 devlink: Fix devlink parallel commands processing
In reply to Sasha LevinFrom: Shay Drory <[email protected]>
[ Upstream commit d7d75124965aee23e5e4421d78376545cf070b0a ]
Commit 870c7ad4a52b ("devlink: protect devlink->dev by the instance lock") added devlink instance locking inside a loop that iterates over all the registered devlink instances on the machine in the pre-doit phase. This can lead to serialization of devlink commands over different devlink instances.
For example: While the first devlink instance is executing firmware flash, all commands to other devlink instances on the machine are forced to wait until the first devlink finishes.
Therefore, in the pre-doit phase, take the devlink instance lock only for the devlink instance the command is targeting. Devlink layer is taking a reference on the devlink instance, ensuring the devlink->dev pointer is valid. This reference taking was introduced by commit a380687200e0 ("devlink: take device reference for devlink object"). Without this commit, it would not be safe to access devlink->dev lockless.
--- net/devlink/netlink.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
net/devlink/netlink.c +7 -6
@@ -80,12 +80,13 @@ devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs, devname =nla_data (attrs[DEVLINK_ATTR_DEV_NAME ]);devlinks_xa_for_each_registered_get (net, index, devlink) { -devl_dev_lock (devlink, dev_lock); -if (devl_is_registered (devlink) && -strcmp (devlink->dev->bus->name, busname) ==0 && -strcmp (dev_name (devlink->dev), devname) ==0 ) -return devlink; -devl_dev_unlock (devlink, dev_lock); +if (strcmp (devlink->dev->bus->name, busname) ==0 && +strcmp (dev_name (devlink->dev), devname) ==0 ) { +devl_dev_lock (devlink, dev_lock); +if (devl_is_registered (devlink)) +return devlink; +devl_dev_unlock (devlink, dev_lock); + }devlink_put (devlink); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 656/713 riscv: Only check online cpus for emulated accesses
In reply to Sasha LevinFrom: Charlie Jenkins <[email protected]>
[ Upstream commit 313130c62cf1fc410ac8730b291fd4fde582d032 ]
The unaligned access checker only sets valid values for online cpus. Check for these values on online cpus rather than on present cpus.
--- arch/riscv/kernel/traps_misaligned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/traps_misaligned.c +1 -1
@@ -632,7 +632,7 @@ void unaligned_emulation_finish(void)* accesses emulated since tasks requesting such control can run on any * CPU. */ -for_each_present_cpu (cpu) { +for_each_online_cpu (cpu) {if (per_cpu (misaligned_access_speed, cpu) !=RISCV_HWPROBE_MISALIGNED_EMULATED ) {return ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 657/713 soc: fsl: dpio: fix kcalloc() argument order
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 72ebb41b88f9d7c10c5e159e0507074af0a22fe2 ]
A previous bugfix added a call to kcalloc(), which starting in gcc-14 causes a harmless warning about the argument order:
drivers/soc/fsl/dpio/dpio-service.c: In function 'dpaa2_io_service_enqueue_multiple_desc_fq':drivers/soc/fsl/dpio/dpio-service.c:526:29: error: 'kcalloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
526 | ed = kcalloc(sizeof(struct qbman_eq_desc), 32, GFP_KERNEL);
| ^~~~~~drivers/soc/fsl/dpio/dpio-service.c:526:29: note: earlier argument should specify number of elements, later size of each element
Since the two are only multiplied, the order does not change the behavior, so just fix it now to shut up the compiler warning.
Dmity independently came up with the same fix.
--- drivers/soc/fsl/dpio/dpio-service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/fsl/dpio/dpio-service.c +1 -1
@@ -523,7 +523,7 @@ int dpaa2_io_service_enqueue_multiple_desc_fq(struct dpaa2_io *d,struct qbman_eq_desc *ed;int i, ret; - ed =kcalloc (sizeof (struct qbman_eq_desc ),32 ,GFP_KERNEL ); + ed =kcalloc (32 ,sizeof (struct qbman_eq_desc ),GFP_KERNEL );if (!ed)return -ENOMEM ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 658/713 cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw()
In reply to Sasha LevinFrom: Sibi Sankar <[email protected]>
[ Upstream commit f37a4d6b4a2c77414e8b9d25dd5ee31537ce9b00 ]
In the existing code, per-policy flags don't have any impact i.e. if cpufreq_driver boost is enabled and boost is disabled for one or more of the policies, the cpufreq driver will behave as if boost is enabled.
Fix this by incorporating per-policy boost flag in the policy->max computation used in cpufreq_frequency_table_cpuinfo and setting the default per-policy boost to mirror the cpufreq_driver boost flag.
--- drivers/cpufreq/cpufreq.c | 18 ++++++++++++------ drivers/cpufreq/freq_table.c | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-)
drivers/cpufreq/cpufreq.c +12 -6
@@ -644,14 +644,16 @@ static ssize_t store_local_boost(struct cpufreq_policy *policy,if (policy->boost_enabled == enable)return count; + policy->boost_enabled = enable; +cpus_read_lock (); ret = cpufreq_driver->set_boost (policy, enable);cpus_read_unlock (); -if (ret) +if (ret) { + policy->boost_enabled = !policy->boost_enabled;return ret; - - policy->boost_enabled = enable; + }return count; }
@@ -1419,6 +1421,9 @@ static int cpufreq_online(unsigned int cpu) goto out_free_policy; } +/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */ + policy->boost_enabled =cpufreq_boost_enabled () &&policy_has_boost_freq (policy); +/* * The initialization has succeeded and the policy is online. * If there is a problem with its frequency table, take it
@@ -2755,11 +2760,12 @@ int cpufreq_boost_trigger_state(int state)cpus_read_lock ();for_each_active_policy (policy) { + policy->boost_enabled = state; ret = cpufreq_driver->set_boost (policy, state); -if (ret) +if (ret) { + policy->boost_enabled = !policy->boost_enabled; goto err_reset_state; - - policy->boost_enabled = state; + } }cpus_read_unlock ();
drivers/cpufreq/freq_table.c +1 -1
@@ -40,7 +40,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,cpufreq_for_each_valid_entry (pos, table) { freq = pos->frequency; -if (!cpufreq_boost_enabled () +if ((!cpufreq_boost_enabled () || !policy->boost_enabled) && (pos->flags &CPUFREQ_BOOST_FREQ ))continue ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 659/713 io_uring: Fix release of pinned pages when __io_uaddr_map fails
In reply to Sasha LevinFrom: Gabriel Krisman Bertazi <[email protected]>
[ Upstream commit 67d1189d1095d471ed7fa426c7e384a7140a5dd7 ]
Looking at the error path of __io_uaddr_map, if we fail after pinning the pages for any reasons, ret will be set to -EINVAL and the error handler won't properly release the pinned pages.
I didn't manage to trigger it without forcing a failure, but it can happen in real life when memory is heavily fragmented.
--- io_uring/io_uring.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
io_uring/io_uring.c +13 -9
@@ -2683,7 +2683,7 @@ static void *__io_uaddr_map(struct page ***pages, unsigned short *npages,struct page **page_array;unsigned int nr_pages;void *page_addr; -int ret, i; +int ret, i, pinned; *npages =0 ;
@@ -2697,12 +2697,12 @@ static void *__io_uaddr_map(struct page ***pages, unsigned short *npages,if (!page_array)return ERR_PTR (-ENOMEM ); - ret =pin_user_pages_fast (uaddr, nr_pages,FOLL_WRITE |FOLL_LONGTERM , - page_array); -if (ret != nr_pages) { -err: -io_pages_free (&page_array, ret >0 ? ret :0 ); -return ret <0 ?ERR_PTR (ret) :ERR_PTR (-EFAULT ); + + pinned =pin_user_pages_fast (uaddr, nr_pages,FOLL_WRITE |FOLL_LONGTERM , + page_array); +if (pinned != nr_pages) { + ret = (pinned <0 ) ? pinned : -EFAULT ; + goto free_pages; } page_addr =page_address (page_array[0 ]);
@@ -2716,7 +2716,7 @@ static void *__io_uaddr_map(struct page ***pages, unsigned short *npages,* didn't support this feature. */ if (PageHighMem (page_array[i])) - goto err; + goto free_pages;/* * No support for discontig pages for now, should either be a
@@ -2725,13 +2725,17 @@ static void *__io_uaddr_map(struct page ***pages, unsigned short *npages,* just fail them with EINVAL. */ if (page_address (page_array[i]) != page_addr) - goto err; + goto free_pages; page_addr +=PAGE_SIZE ; } *pages = page_array; *npages = nr_pages;return page_to_virt (page_array[0 ]); + +free_pages: +io_pages_free (&page_array, pinned >0 ? pinned :0 ); +return ERR_PTR (ret); } static void *io_rings_map(struct io_ring_ctx *ctx, unsigned long uaddr,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 660/713 tcp: Fix refcnt handling in __inet_hash_connect().
In reply to Sasha LevinFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 04d9d1fc428ac9f581d55118d67e0cb546701feb ]
syzbot reported a warning in sk_nulls_del_node_init_rcu().
The commit 66b60b0c8c4a ("dccp/tcp: Unhash sk from ehash for tb2 alloc failure after check_estalblished().") tried to fix an issue that an unconnected socket occupies an ehash entry when bhash2 allocation fails.
In such a case, we need to revert changes done by check_established(), which does not hold refcnt when inserting socket into ehash.
So, to revert the change, we need to __sk_nulls_add_node_rcu() instead of sk_nulls_add_node_rcu().
Otherwise, sock_put() will cause refcnt underflow and leak the socket.
[0]:
WARNING: CPU: 0 PID: 23948 at include/net/sock.h:799 sk_nulls_del_node_init_rcu+0x166/0x1a0 include/net/sock.h:799 Modules linked in: CPU: 0 PID: 23948 Comm: syz-executor.2 Not tainted 6.8.0-rc6-syzkaller-00159-gc055fc00c07b #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024 RIP: 0010:sk_nulls_del_node_init_rcu+0x166/0x1a0 include/net/sock.h:799 Code: e8 7f 71 c6 f7 83 fb 02 7c 25 e8 35 6d c6 f7 4d 85 f6 0f 95 c0 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc e8 1b 6d c6 f7 90 <0f> 0b 90 eb b2 e8 10 6d c6 f7 4c 89 e7 be 04 00 00 00 e8 63 e7 d2 RSP: 0018:ffffc900032d7848 EFLAGS: 00010246 RAX: ffffffff89cd0035 RBX: 0000000000000001 RCX: 0000000000040000 RDX: ffffc90004de1000 RSI: 000000000003ffff RDI: 0000000000040000 RBP: 1ffff1100439ac26 R08: ffffffff89ccffe3 R09: 1ffff1100439ac28 R10: dffffc0000000000 R11: ffffed100439ac29 R12: ffff888021cd6140 R13: dffffc0000000000 R14: ffff88802a9bf5c0 R15: ffff888021cd6130 FS: 00007f3b823f16c0(0000) GS:ffff8880b9400000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f3b823f0ff8 CR3: 000000004674a000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> __inet_hash_connect+0x140f/0x20b0 net/ipv4/inet_hashtables.c:1139 dccp_v6_connect+0xcb9/0x1480 net/dccp/ipv6.c:956 __inet_stream_connect+0x262/0xf30 net/ipv4/af_inet.c:678 inet_stream_connect+0x65/0xa0 net/ipv4/af_inet.c:749 __sys_connect_file net/socket.c:2048 [inline] __sys_connect+0x2df/0x310 net/socket.c:2065 __do_sys_connect net/socket.c:2075 [inline] __se_sys_connect net/socket.c:2072 [inline] __x64_sys_connect+0x7a/0x90 net/socket.c:2072 do_syscall_64+0xf9/0x240 entry_SYSCALL_64_after_hwframe+0x6f/0x77 RIP: 0033:0x7f3b8167dda9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f3b823f10c8 EFLAGS: 00000246 ORIG_RAX: 000000000000002a RAX: ffffffffffffffda RBX: 00007f3b817abf80 RCX: 00007f3b8167dda9 RDX: 000000000000001c RSI: 0000000020000040 RDI: 0000000000000003 RBP: 00007f3b823f1120 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001 R13: 000000000000000b R14: 00007f3b817abf80 R15: 00007ffd3beb57b8 </TASK>
--- net/ipv4/inet_hashtables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/inet_hashtables.c +1 -1
@@ -1137,7 +1137,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,sock_prot_inuse_add (net, sk->sk_prot,-1 );spin_lock (lock); -sk_nulls_del_node_init_rcu (sk); +__sk_nulls_del_node_init_rcu (sk);spin_unlock (lock); sk->sk_hash =0 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 661/713 vmxnet3: Fix missing reserved tailroom
In reply to Sasha LevinFrom: William Tu <[email protected]>
[ Upstream commit e127ce7699c1e05279ee5ee61f00893e7bfa9671 ]
Use rbi->len instead of rcd->len for non-dataring packet.
Found issue:
XDP_WARN: xdp_update_frame_from_buff(line:278): Driver BUG: missing reserved tailroom
WARNING: CPU: 0 PID: 0 at net/core/xdp.c:586 xdp_warn+0xf/0x20 CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W O 6.5.1 #1 RIP: 0010:xdp_warn+0xf/0x20 ... ? xdp_warn+0xf/0x20 xdp_do_redirect+0x15f/0x1c0 vmxnet3_run_xdp+0x17a/0x400 [vmxnet3] vmxnet3_process_xdp+0xe4/0x760 [vmxnet3] ? vmxnet3_tq_tx_complete.isra.0+0x21e/0x2c0 [vmxnet3] vmxnet3_rq_rx_complete+0x7ad/0x1120 [vmxnet3] vmxnet3_poll_rx_only+0x2d/0xa0 [vmxnet3] __napi_poll+0x20/0x180 net_rx_action+0x177/0x390
--- drivers/net/vmxnet3/vmxnet3_xdp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/vmxnet3/vmxnet3_xdp.c +3 -3
@@ -382,12 +382,12 @@ vmxnet3_process_xdp(struct vmxnet3_adapter *adapter, page = rbi->page;dma_sync_single_for_cpu (&adapter->pdev->dev,page_pool_get_dma_addr (page) + - rq->page_pool->p.offset, rcd->len, + rq->page_pool->p.offset, rbi->len,page_pool_get_dma_dir (rq->page_pool)); -xdp_init_buff (&xdp, rbi->len, &rq->xdp_rxq); +xdp_init_buff (&xdp,PAGE_SIZE , &rq->xdp_rxq);xdp_prepare_buff (&xdp,page_address (page), rq->page_pool->p.offset, - rcd->len, false); + rbi->len, false);xdp_buff_clear_frags_flag (&xdp); xdp_prog =rcu_dereference (rq->adapter->xdp_bpf_prog);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 662/713 hsr: Fix uninit-value access in hsr_get_node()
In reply to Sasha LevinFrom: Shigeru Yoshida <[email protected]>
[ Upstream commit ddbec99f58571301679addbc022256970ca3eac6 ]
KMSAN reported the following uninit-value access issue [1]:
=====================================================
BUG: KMSAN: uninit-value in hsr_get_node+0xa2e/0xa40 net/hsr/hsr_framereg.c:246 hsr_get_node+0xa2e/0xa40 net/hsr/hsr_framereg.c:246 fill_frame_info net/hsr/hsr_forward.c:577 [inline] hsr_forward_skb+0xe12/0x30e0 net/hsr/hsr_forward.c:615 hsr_dev_xmit+0x1a1/0x270 net/hsr/hsr_device.c:223 __netdev_start_xmit include/linux/netdevice.h:4940 [inline] netdev_start_xmit include/linux/netdevice.h:4954 [inline] xmit_one net/core/dev.c:3548 [inline] dev_hard_start_xmit+0x247/0xa10 net/core/dev.c:3564 __dev_queue_xmit+0x33b8/0x5130 net/core/dev.c:4349 dev_queue_xmit include/linux/netdevice.h:3134 [inline] packet_xmit+0x9c/0x6b0 net/packet/af_packet.c:276 packet_snd net/packet/af_packet.c:3087 [inline] packet_sendmsg+0x8b1d/0x9f30 net/packet/af_packet.c:3119 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg net/socket.c:745 [inline] __sys_sendto+0x735/0xa10 net/socket.c:2191 __do_sys_sendto net/socket.c:2203 [inline] __se_sys_sendto net/socket.c:2199 [inline] __x64_sys_sendto+0x125/0x1c0 net/socket.c:2199 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x6d/0x140 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x63/0x6b
Uninit was created at:
slab_post_alloc_hook+0x129/0xa70 mm/slab.h:768 slab_alloc_node mm/slub.c:3478 [inline] kmem_cache_alloc_node+0x5e9/0xb10 mm/slub.c:3523 kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:560 __alloc_skb+0x318/0x740 net/core/skbuff.c:651 alloc_skb include/linux/skbuff.h:1286 [inline] alloc_skb_with_frags+0xc8/0xbd0 net/core/skbuff.c:6334 sock_alloc_send_pskb+0xa80/0xbf0 net/core/sock.c:2787 packet_alloc_skb net/packet/af_packet.c:2936 [inline] packet_snd net/packet/af_packet.c:3030 [inline] packet_sendmsg+0x70e8/0x9f30 net/packet/af_packet.c:3119 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg net/socket.c:745 [inline] __sys_sendto+0x735/0xa10 net/socket.c:2191 __do_sys_sendto net/socket.c:2203 [inline] __se_sys_sendto net/socket.c:2199 [inline] __x64_sys_sendto+0x125/0x1c0 net/socket.c:2199 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x6d/0x140 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x63/0x6b CPU: 1 PID: 5033 Comm: syz-executor334 Not tainted 6.7.0-syzkaller-00562-g9f8413c4a66f #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023 =====================================================
If the packet type ID field in the Ethernet header is either ETH_P_PRP or ETH_P_HSR, but it is not followed by an HSR tag, hsr_get_skb_sequence_nr() reads an invalid value as a sequence number. This causes the above issue.
This patch fixes the issue by returning NULL if the Ethernet header is not followed by an HSR tag.
--- net/hsr/hsr_framereg.c | 4 ++++ 1 file changed, 4 insertions(+)
net/hsr/hsr_framereg.c +4 -0
@@ -228,6 +228,10 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,*/ if (ethhdr->h_proto ==htons (ETH_P_PRP ) || ethhdr->h_proto ==htons (ETH_P_HSR )) { +/* Check if skb contains hsr_ethhdr */ +if (skb->mac_len <sizeof (struct hsr_ethhdr )) +return NULL ; +/* Use the existing sequence_nr from the tag as starting point * for filtering duplicate frames. */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 663/713 net: txgbe: fix clk_name exceed MAX_DEV_ID limits
In reply to Sasha LevinFrom: Duanqiang Wen <[email protected]>
[ Upstream commit e30cef001da259e8df354b813015d0e5acc08740 ]
txgbe register clk which name is i2c_designware.pci_dev_id(), clk_name will be stored in clk_lookup_alloc. If PCIe bus number is larger than 0x39, clk_name size will be larger than 20 bytes. It exceeds clk_lookup_alloc MAX_DEV_ID limits. So the driver shortened clk_name.
--- drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c +1 -1
@@ -551,7 +551,7 @@ static int txgbe_clock_register(struct txgbe *txgbe)char clk_name[32 ];struct clk *clk; -snprintf (clk_name,sizeof (clk_name),"i2c_designware.%d" , +snprintf (clk_name,sizeof (clk_name),"i2c_dw.%d" ,pci_dev_id (pdev)); clk =clk_register_fixed_rate (NULL , clk_name,NULL ,0 ,156250000 );
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 664/713 nvme: fix reconnection fail due to reserved tag allocation
In reply to Sasha LevinFrom: Chunguang Xu <[email protected]>
[ Upstream commit de105068fead55ed5c07ade75e9c8e7f86a00d1d ]
We found a issue on production environment while using NVMe over RDMA, admin_q reconnect failed forever while remote target and network is ok. After dig into it, we found it may caused by a ABBA deadlock due to tag allocation. In my case, the tag was hold by a keep alive request waiting inside admin_q, as we quiesced admin_q while reset ctrl, so the request maked as idle and will not process before reset success. As fabric_q shares tagset with admin_q, while reconnect remote target, we need a tag for connect command, but the only one reserved tag was held by keep alive command which waiting inside admin_q. As a result, we failed to reconnect admin_q forever. In order to fix this issue, I think we should keep two reserved tags for admin queue.
--- drivers/nvme/host/core.c | 6 ++++-- drivers/nvme/host/fabrics.h | 7 ------- 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/nvme/host/core.c +4 -2
@@ -4272,7 +4272,8 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set, set->ops = ops; set->queue_depth =NVME_AQ_MQ_TAG_DEPTH ;if (ctrl->ops->flags &NVME_F_FABRICS ) - set->reserved_tags =NVMF_RESERVED_TAGS ; +/* Reserved for fabric connect and keep alive */ + set->reserved_tags =2 ; set->numa_node = ctrl->numa_node; set->flags =BLK_MQ_F_NO_SCHED ;if (ctrl->ops->flags &NVME_F_BLOCKING )
@@ -4341,7 +4342,8 @@ int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,if (ctrl->quirks &NVME_QUIRK_SHARED_TAGS ) set->reserved_tags =NVME_AQ_DEPTH ;else if (ctrl->ops->flags &NVME_F_FABRICS ) - set->reserved_tags =NVMF_RESERVED_TAGS ; +/* Reserved for fabric connect */ + set->reserved_tags =1 ; set->numa_node = ctrl->numa_node; set->flags =BLK_MQ_F_SHOULD_MERGE ;if (ctrl->ops->flags &NVME_F_BLOCKING )
drivers/nvme/host/fabrics.h +0 -7
@@ -18,13 +18,6 @@/* default is -1: the fail fast mechanism is disabled */ #define NVMF_DEF_FAIL_FAST_TMO -1 -/* -* Reserved one command for internal usage. This command is used for sending -* the connect command, as well as for the keep alive command on the admin -* queue once live. -*/ -#define NVMF_RESERVED_TAGS 1 -/* * Define a host as seen by the target. We allocate one at boot, but also * allow the override it when creating controllers. This is both to provide
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 665/713 net: mediatek: mtk_eth_soc: clear MAC_MCR_FORCE_LINK only when MAC is up
In reply to Sasha LevinFrom: Daniel Golle <[email protected]>
[ Upstream commit f1b85ef15a99f06ed48871ce933d591127d2dcc0 ]
Clearing bit MAC_MCR_FORCE_LINK which forces the link down too early can result in MAC ending up in a broken/blocked state.
Fix this by handling this bit in the .mac_link_up and .mac_link_down calls instead of in .mac_finish.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +3 -4
@@ -677,8 +677,7 @@ static int mtk_mac_finish(struct phylink_config *config, unsigned int mode, mcr_cur =mtk_r32 (mac->hw,MTK_MAC_MCR (mac->id)); mcr_new = mcr_cur; mcr_new |=MAC_MCR_IPG_CFG |MAC_MCR_FORCE_MODE | -MAC_MCR_BACKOFF_EN |MAC_MCR_BACKPR_EN |MAC_MCR_FORCE_LINK | -MAC_MCR_RX_FIFO_CLR_DIS ; +MAC_MCR_BACKOFF_EN |MAC_MCR_BACKPR_EN |MAC_MCR_RX_FIFO_CLR_DIS ;/* Only update control register when needed! */ if (mcr_new != mcr_cur)
@@ -694,7 +693,7 @@ static void mtk_mac_link_down(struct phylink_config *config, unsigned int mode, phylink_config);u32 mcr =mtk_r32 (mac->hw,MTK_MAC_MCR (mac->id)); - mcr &= ~(MAC_MCR_TX_EN |MAC_MCR_RX_EN ); + mcr &= ~(MAC_MCR_TX_EN |MAC_MCR_RX_EN |MAC_MCR_FORCE_LINK );mtk_w32 (mac->hw, mcr,MTK_MAC_MCR (mac->id)); }
@@ -803,7 +802,7 @@ static void mtk_mac_link_up(struct phylink_config *config,if (rx_pause) mcr |=MAC_MCR_FORCE_RX_FC ; - mcr |=MAC_MCR_TX_EN |MAC_MCR_RX_EN ; + mcr |=MAC_MCR_TX_EN |MAC_MCR_RX_EN |MAC_MCR_FORCE_LINK ;mtk_w32 (mac->hw, mcr,MTK_MAC_MCR (mac->id)); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 666/713 net: ethernet: mtk_eth_soc: fix PPE hanging issue
In reply to Sasha LevinFrom: Daniel Golle <[email protected]>
[ Upstream commit ea80e3ed09ab2c2b75724faf5484721753e92c31 ]
A patch to resolve an issue was found in MediaTek's GPL-licensed SDK:
In the mtk_ppe_stop() function, the PPE scan mode is not disabled before disabling the PPE. This can potentially lead to a hang during the process of disabling the PPE.
Without this patch, the PPE may experience a hang during the reboot test.
--- drivers/net/ethernet/mediatek/mtk_ppe.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/net/ethernet/mediatek/mtk_ppe.c +11 -7
@@ -994,7 +994,7 @@ void mtk_ppe_start(struct mtk_ppe *ppe) MTK_PPE_KEEPALIVE_DISABLE) |FIELD_PREP (MTK_PPE_TB_CFG_HASH_MODE ,1 ) |FIELD_PREP (MTK_PPE_TB_CFG_SCAN_MODE , -MTK_PPE_SCAN_MODE_KEEPALIVE_AGE ) | +MTK_PPE_SCAN_MODE_CHECK_AGE ) |FIELD_PREP (MTK_PPE_TB_CFG_ENTRY_NUM ,MTK_PPE_ENTRIES_SHIFT );if (mtk_is_netsys_v2_or_greater (ppe->eth))
@@ -1090,17 +1090,21 @@ int mtk_ppe_stop(struct mtk_ppe *ppe)mtk_ppe_cache_enable (ppe, false); -/* disable offload engine */ -ppe_clear (ppe,MTK_PPE_GLO_CFG ,MTK_PPE_GLO_CFG_EN ); -ppe_w32 (ppe,MTK_PPE_FLOW_CFG ,0 ); -/* disable aging */ val =MTK_PPE_TB_CFG_AGE_NON_L4 |MTK_PPE_TB_CFG_AGE_UNBIND |MTK_PPE_TB_CFG_AGE_TCP |MTK_PPE_TB_CFG_AGE_UDP | -MTK_PPE_TB_CFG_AGE_TCP_FIN ; +MTK_PPE_TB_CFG_AGE_TCP_FIN | +MTK_PPE_TB_CFG_SCAN_MODE ;ppe_clear (ppe,MTK_PPE_TB_CFG , val); -return mtk_ppe_wait_busy (ppe); +if (mtk_ppe_wait_busy (ppe)) +return -ETIMEDOUT ; + +/* disable offload engine */ +ppe_clear (ppe,MTK_PPE_GLO_CFG ,MTK_PPE_GLO_CFG_EN ); +ppe_w32 (ppe,MTK_PPE_FLOW_CFG ,0 ); + +return 0 ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 667/713 io_uring: fix poll_remove stalled req completion
In reply to Sasha LevinFrom: Pavel Begunkov <[email protected]>
[ Upstream commit 5e3afe580a9f5ca173a6bd55ffe10948796ef7e5 ]
Taking the ctx lock is not enough to use the deferred request completion infrastructure, it'll get queued into the list but no one would expect it there, so it will sit there until next io_submit_flush_completions(). It's hard to care about the cancellation path, so complete it via tw.
--- io_uring/poll.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
io_uring/poll.c +2 -2
@@ -995,7 +995,6 @@ int io_poll_remove(struct io_kiocb *req, unsigned int issue_flags)struct io_hash_bucket *bucket;struct io_kiocb *preq;int ret2, ret =0 ; -struct io_tw_state ts = { .locked = true };io_ring_submit_lock (ctx, issue_flags); preq =io_poll_find (ctx, true, &cd, &ctx->cancel_table, &bucket);
@@ -1044,7 +1043,8 @@ int io_poll_remove(struct io_kiocb *req, unsigned int issue_flags)req_set_fail (preq);io_req_set_res (preq, -ECANCELED ,0 ); -io_req_task_complete (preq, &ts); + preq->io_task_work.func = io_req_task_complete; +io_req_task_work_add (preq); out:io_ring_submit_unlock (ctx, issue_flags);if (ret <0 ) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 668/713 riscv: Fix compilation error with FAST_GUP and rv32
In reply to Sasha LevinFrom: Alexandre Ghiti <[email protected]>
[ Upstream commit 2bb7e0c49302feec1c2f777bbfe8726169986ed8 ]
By surrounding the definition of pte_leaf_size() with a ifdef napot as it should have been.
--- arch/riscv/include/asm/pgtable.h | 2 ++ 1 file changed, 2 insertions(+)
arch/riscv/include/asm/pgtable.h +2 -0
@@ -439,9 +439,11 @@ static inline pte_t pte_mkhuge(pte_t pte)return pte; } +#ifdef CONFIG_RISCV_ISA_SVNAPOT #define pte_leaf_size (pte) (pte_napot(pte) ? \ napot_cont_size(napot_cont_order(pte)) :\ PAGE_SIZE) +#endif #ifdef CONFIG_NUMA_BALANCING /*
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 669/713 xen/evtchn: avoid WARN() when unbinding an event channel
In reply to Sasha LevinFrom: Juergen Gross <[email protected]>
[ Upstream commit 51c23bd691c0f1fb95b29731c356c6fd69925d17 ]
When unbinding a user event channel, the related handler might be called a last time in case the kernel was built with CONFIG_DEBUG_SHIRQ. This might cause a WARN() in the handler.
Avoid that by adding an "unbinding" flag to struct user_event which will short circuit the handler.
--- drivers/xen/evtchn.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/xen/evtchn.c +6 -0
@@ -85,6 +85,7 @@ struct user_evtchn {struct per_user_data *user;evtchn_port_t port;bool enabled; +bool unbinding; };static void evtchn_free_ring (evtchn_port_t *ring)
@@ -164,6 +165,10 @@ static irqreturn_t evtchn_interrupt(int irq, void *data)struct per_user_data *u = evtchn->user;unsigned int prod, cons; +/* Handler might be called when tearing down the IRQ. */ +if (evtchn->unbinding) +return IRQ_HANDLED ; +WARN (!evtchn->enabled,"Interrupt for port %u, but apparently not enabled; per-user %p\n" , evtchn->port, u);
@@ -421,6 +426,7 @@ static void evtchn_unbind_from_user(struct per_user_data *u,BUG_ON (irq <0 ); + evtchn->unbinding = true;unbind_from_irqhandler (irq, evtchn);del_evtchn (u, evtchn);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 670/713 xen/events: increment refcnt only if event channel is refcounted
In reply to Sasha LevinFrom: Juergen Gross <[email protected]>
[ Upstream commit d277f9d82802223f242cd9b60c988cfdda1d6be0 ]
In bind_evtchn_to_irq_chip() don't increment the refcnt of the event channel blindly. In case the event channel is NOT refcounted, issue a warning instead.
Add an additional safety net by doing the refcnt increment only if the caller has specified IRQF_SHARED in the irqflags parameter.
--- drivers/xen/events/events_base.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
drivers/xen/events/events_base.c +13 -9
@@ -1190,7 +1190,7 @@ int xen_pirq_from_irq(unsigned irq)EXPORT_SYMBOL_GPL (xen_pirq_from_irq);static int bind_evtchn_to_irq_chip (evtchn_port_t evtchn,struct irq_chip *chip, -struct xenbus_device *dev) +struct xenbus_device *dev,bool shared) {int ret = -ENOMEM ;struct irq_info *info;
@@ -1224,7 +1224,8 @@ static int bind_evtchn_to_irq_chip(evtchn_port_t evtchn, struct irq_chip *chip,*/ bind_evtchn_to_cpu (info,0 , false); }else if (!WARN_ON (info->type !=IRQT_EVTCHN )) { - info->refcnt++; +if (shared && !WARN_ON (info->refcnt <0 )) + info->refcnt++; } ret = info->irq;
@@ -1237,13 +1238,13 @@ static int bind_evtchn_to_irq_chip(evtchn_port_t evtchn, struct irq_chip *chip,int bind_evtchn_to_irq (evtchn_port_t evtchn) { -return bind_evtchn_to_irq_chip (evtchn, &xen_dynamic_chip,NULL ); +return bind_evtchn_to_irq_chip (evtchn, &xen_dynamic_chip,NULL , false); }EXPORT_SYMBOL_GPL (bind_evtchn_to_irq);int bind_evtchn_to_irq_lateeoi (evtchn_port_t evtchn) { -return bind_evtchn_to_irq_chip (evtchn, &xen_lateeoi_chip,NULL ); +return bind_evtchn_to_irq_chip (evtchn, &xen_lateeoi_chip,NULL , false); }EXPORT_SYMBOL_GPL (bind_evtchn_to_irq_lateeoi);
@@ -1295,7 +1296,8 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)static int bind_interdomain_evtchn_to_irq_chip (struct xenbus_device *dev,evtchn_port_t remote_port, -struct irq_chip *chip) +struct irq_chip *chip, +bool shared) {struct evtchn_bind_interdomain bind_interdomain;int err;
@@ -1307,14 +1309,14 @@ static int bind_interdomain_evtchn_to_irq_chip(struct xenbus_device *dev, &bind_interdomain);return err ? :bind_evtchn_to_irq_chip (bind_interdomain.local_port, - chip, dev); + chip, dev, shared); }int bind_interdomain_evtchn_to_irq_lateeoi (struct xenbus_device *dev,evtchn_port_t remote_port) {return bind_interdomain_evtchn_to_irq_chip (dev, remote_port, - &xen_lateeoi_chip); + &xen_lateeoi_chip, false); }EXPORT_SYMBOL_GPL (bind_interdomain_evtchn_to_irq_lateeoi);
@@ -1430,7 +1432,8 @@ static int bind_evtchn_to_irqhandler_chip(evtchn_port_t evtchn, {int irq, retval; - irq =bind_evtchn_to_irq_chip (evtchn, chip,NULL ); + irq =bind_evtchn_to_irq_chip (evtchn, chip,NULL , + irqflags &IRQF_SHARED );if (irq <0 )return irq; retval =request_irq (irq, handler, irqflags, devname, dev_id);
@@ -1471,7 +1474,8 @@ static int bind_interdomain_evtchn_to_irqhandler_chip( {int irq, retval; - irq =bind_interdomain_evtchn_to_irq_chip (dev, remote_port, chip); + irq =bind_interdomain_evtchn_to_irq_chip (dev, remote_port, chip, + irqflags &IRQF_SHARED );if (irq <0 )return irq;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 671/713 packet: annotate data-races around ignore_outgoing
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 6ebfad33161afacb3e1e59ed1c2feefef70f9f97 ]
ignore_outgoing is read locklessly from dev_queue_xmit_nit() and packet_getsockopt()
Add appropriate READ_ONCE()/WRITE_ONCE() annotations.
syzbot reported:
BUG: KCSAN: data-race in dev_queue_xmit_nit / packet_setsockopt
write to 0xffff888107804542 of 1 bytes by task 22618 on cpu 0:
packet_setsockopt+0xd83/0xfd0 net/packet/af_packet.c:4003 do_sock_setsockopt net/socket.c:2311 [inline] __sys_setsockopt+0x1d8/0x250 net/socket.c:2334 __do_sys_setsockopt net/socket.c:2343 [inline] __se_sys_setsockopt net/socket.c:2340 [inline] __x64_sys_setsockopt+0x66/0x80 net/socket.c:2340 do_syscall_64+0xd3/0x1d0 entry_SYSCALL_64_after_hwframe+0x6d/0x75
read to 0xffff888107804542 of 1 bytes by task 27 on cpu 1:
dev_queue_xmit_nit+0x82/0x620 net/core/dev.c:2248 xmit_one net/core/dev.c:3527 [inline] dev_hard_start_xmit+0xcc/0x3f0 net/core/dev.c:3547 __dev_queue_xmit+0xf24/0x1dd0 net/core/dev.c:4335 dev_queue_xmit include/linux/netdevice.h:3091 [inline] batadv_send_skb_packet+0x264/0x300 net/batman-adv/send.c:108 batadv_send_broadcast_skb+0x24/0x30 net/batman-adv/send.c:127 batadv_iv_ogm_send_to_if net/batman-adv/bat_iv_ogm.c:392 [inline] batadv_iv_ogm_emit net/batman-adv/bat_iv_ogm.c:420 [inline] batadv_iv_send_outstanding_bat_ogm_packet+0x3f0/0x4b0 net/batman-adv/bat_iv_ogm.c:1700 process_one_work kernel/workqueue.c:3254 [inline] process_scheduled_works+0x465/0x990 kernel/workqueue.c:3335 worker_thread+0x526/0x730 kernel/workqueue.c:3416 kthread+0x1d1/0x210 kernel/kthread.c:388 ret_from_fork+0x4b/0x60 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:243
value changed: 0x00 -> 0x01
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 27 Comm: kworker/u8:1 Tainted: G W 6.8.0-syzkaller-08073-g480e035fc4c7 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/29/2024 Workqueue: bat_events batadv_iv_send_outstanding_bat_ogm_packet
--- net/core/dev.c | 2 +- net/packet/af_packet.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
net/core/dev.c +1 -1
@@ -2262,7 +2262,7 @@ void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)rcu_read_lock (); again:list_for_each_entry_rcu (ptype, ptype_list, list) { -if (ptype->ignore_outgoing) +if (READ_ONCE (ptype->ignore_outgoing))continue ;/* Never send packets back to the socket
net/packet/af_packet.c +2 -2
@@ -4004,7 +4004,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, sockptr_t optval,if (val <0 || val >1 )return -EINVAL ; - po->prot_hook.ignore_outgoing = !!val; +WRITE_ONCE (po->prot_hook.ignore_outgoing, !!val);return 0 ; }case PACKET_TX_HAS_OFF :
@@ -4135,7 +4135,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, 0);break ;case PACKET_IGNORE_OUTGOING : - val = po->prot_hook.ignore_outgoing; + val =READ_ONCE (po->prot_hook.ignore_outgoing);break ;case PACKET_ROLLOVER_STATS :if (!po->rollover)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 672/713 xfrm: Allow UDP encapsulation only in offload modes
In reply to Sasha LevinFrom: Leon Romanovsky <[email protected]>
[ Upstream commit 773bb766ca4a05bf363203030b72b10088869224 ]
The missing check of x->encap caused to the situation where GSO packets were created with UDP encapsulation.
As a solution return the encap check for non-offloaded SA.
--- net/xfrm/xfrm_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/xfrm/xfrm_device.c +2 -1
@@ -407,7 +407,8 @@ bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x)struct xfrm_dst *xdst = (struct xfrm_dst *)dst;struct net_device *dev = x->xso.dev; -if (!x->type_offload) +if (!x->type_offload || + (x->xso.type ==XFRM_DEV_OFFLOAD_UNSPECIFIED && x->encap))return false; if (x->xso.type == XFRM_DEV_OFFLOAD_PACKET ||
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 673/713 net: veth: do not manipulate GRO when using XDP
In reply to Sasha LevinFrom: Ignat Korchagin <[email protected]>
[ Upstream commit d7db7775ea2e31502d46427f5efd385afc4ff1eb ]
Commit d3256efd8e8b ("veth: allow enabling NAPI even without XDP") tried to fix the fact that GRO was not possible without XDP, because veth did not use NAPI without XDP. However, it also introduced the behaviour that GRO is always enabled, when XDP is enabled.
While it might be desired for most cases, it is confusing for the user at best as the GRO flag suddenly changes, when an XDP program is attached. It also introduces some complexities in state management as was partially addressed in commit fe9f801355f0 ("net: veth: clear GRO when clearing XDP even when down").
But the biggest problem is that it is not possible to disable GRO at all, when an XDP program is attached, which might be needed for some use cases.
Fix this by not touching the GRO flag on XDP enable/disable as the code already supports switching to NAPI if either GRO or XDP is requested.
--- drivers/net/veth.c | 18 ------------------ 1 file changed, 18 deletions(-)
drivers/net/veth.c +0 -18
@@ -1533,8 +1533,6 @@ static netdev_features_t veth_fix_features(struct net_device *dev,if (peer_priv->_xdp_prog) features &= ~NETIF_F_GSO_SOFTWARE ; } -if (priv->_xdp_prog) - features |=NETIF_F_GRO ;return features; }
@@ -1638,14 +1636,6 @@ static int veth_xdp_set(struct net_device *dev, struct bpf_prog *prog, }if (!old_prog) { -if (!veth_gro_requested (dev)) { -/* user-space did not require GRO, but adding -* XDP is supposed to get GRO working -*/ - dev->features |=NETIF_F_GRO ; -netdev_features_change (dev); - } - peer->hw_features &= ~NETIF_F_GSO_SOFTWARE ; peer->max_mtu = max_mtu; }
@@ -1661,14 +1651,6 @@ static int veth_xdp_set(struct net_device *dev, struct bpf_prog *prog,if (dev->flags &IFF_UP )veth_disable_xdp (dev); -/* if user-space did not require GRO, since adding XDP -* enabled it, clear it now -*/ -if (!veth_gro_requested (dev)) { - dev->features &= ~NETIF_F_GRO ; -netdev_features_change (dev); - } -if (peer) { peer->hw_features |=NETIF_F_GSO_SOFTWARE ; peer->max_mtu =ETH_MAX_MTU ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 674/713 net: dsa: mt7530: prevent possible incorrect XTAL frequency selection
In reply to Sasha LevinFrom: Arınç ÜNAL <[email protected]>
[ Upstream commit f490c492e946d8ffbe65ad4efc66de3c5ede30a4 ]
On MT7530, the HT_XTAL_FSEL field of the HWTRAP register stores a 2-bit value that represents the frequency of the crystal oscillator connected to the switch IC. The field is populated by the state of the ESW_P4_LED_0 and ESW_P4_LED_0 pins, which is done right after reset is deasserted.
ESW_P4_LED_0 ESW_P3_LED_0 Frequency
-----------------------------------------
0 0 Reserved 0 1 20MHz 1 0 40MHz 1 1 25MHz
On MT7531, the XTAL25 bit of the STRAP register stores this. The LAN0LED0 pin is used to populate the bit. 25MHz when the pin is high, 40MHz when it's low.
These pins are also used with LEDs, therefore, their state can be set to something other than the bootstrapping configuration. For example, a link may be established on port 3 before the DSA subdriver takes control of the switch which would set ESW_P3_LED_0 to high.
Currently on mt7530_setup() and mt7531_setup(), 1000 - 1100 usec delay is described between reset assertion and deassertion. Some switch ICs in real life conditions cannot always have these pins set back to the bootstrapping configuration before reset deassertion in this amount of delay. This causes wrong crystal frequency to be selected which puts the switch in a nonfunctional state after reset deassertion.
The tests below are conducted on an MT7530 with a 40MHz crystal oscillator by Justin Swartz.
With a cable from an active peer connected to port 3 before reset, an incorrect crystal frequency (0b11 = 25MHz) is selected:
[1] [3] [5]
: : :
_____________________________ __________________
ESW_P4_LED_0 |_______|
_____________________________ESW_P3_LED_0 |__________________________
: : : :
: : [4]...:
: :
[2]................:[1] Reset is asserted.
[2] Period of 1000 - 1100 usec.
[3] Reset is deasserted.
[4] Period of 315 usec. HWTRAP register is populated with incorrect XTAL frequency.
[5] Signals reflect the bootstrapped configuration.
Increase the delay between reset_control_assert() and reset_control_deassert(), and gpiod_set_value_cansleep(priv->reset, 0) and gpiod_set_value_cansleep(priv->reset, 1) to 5000 - 5100 usec. This amount ensures a higher possibility that the switch IC will have these pins back to the bootstrapping configuration before reset deassertion.
With a cable from an active peer connected to port 3 before reset, the correct crystal frequency (0b10 = 40MHz) is selected:
[1] [2-1] [3] [5]
: : : :
_____________________________ __________________
ESW_P4_LED_0 |_______|
___________________ _______ESW_P3_LED_0 |_________| |__________________
: : : : :
: [2-2]...: [4]...:
[2]................:[1] Reset is asserted.
[2] Period of 5000 - 5100 usec.
[2-1] ESW_P3_LED_0 goes low.
[2-2] Remaining period of 5000 - 5100 usec.
[3] Reset is deasserted.
[4] Period of 310 usec. HWTRAP register is populated with bootstrapped XTAL frequency.
[5] Signals reflect the bootstrapped configuration.
ESW_P3_LED_0 low period before reset deassertion:
5000 usec
- 5100 usec
TEST RESET HOLD
# (usec)
---------------------
1 5410
2 5440
3 4375
4 5490
5 5475
6 4335
7 4370
8 5435
9 4205
10 4335
11 3750
12 3170
13 4395
14 4375
15 3515
16 4335
17 4220
18 4175
19 4175
20 4350 Min 3170
Max 5490
Median 4342.500
Avg 4466.500
Revert commit 2920dd92b980 ("net: dsa: mt7530: disable LEDs before reset"). Changing the state of pins via reset assertion is simpler and more efficient than doing so by setting the LED controller off.
--- drivers/net/dsa/mt7530.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/dsa/mt7530.c +4 -4
@@ -2243,11 +2243,11 @@ mt7530_setup(struct dsa_switch *ds)*/ if (priv->mcm) {reset_control_assert (priv->rstc); -usleep_range (1000 ,1100 ); +usleep_range (5000 ,5100 );reset_control_deassert (priv->rstc); }else {gpiod_set_value_cansleep (priv->reset,0 ); -usleep_range (1000 ,1100 ); +usleep_range (5000 ,5100 );gpiod_set_value_cansleep (priv->reset,1 ); }
@@ -2449,11 +2449,11 @@ mt7531_setup(struct dsa_switch *ds)*/ if (priv->mcm) {reset_control_assert (priv->rstc); -usleep_range (1000 ,1100 ); +usleep_range (5000 ,5100 );reset_control_deassert (priv->rstc); }else {gpiod_set_value_cansleep (priv->reset,0 ); -usleep_range (1000 ,1100 ); +usleep_range (5000 ,5100 );gpiod_set_value_cansleep (priv->reset,1 ); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 675/713 spi: spi-imx: fix off-by-one in mx51 CPU mode burst length
In reply to Sasha LevinFrom: Adam Butcher <[email protected]>
[ Upstream commit cf6d79a0f5769b5f4d9579ddaf88d2c30b03b873 ]
c712c05e46c8 ("spi: imx: fix the burst length at DMA mode and CPU mode") corrects three cases of setting the ECSPI burst length but erroneously leaves the in-range CPU case one bit to big (in that field a value of 0 means 1 bit). The effect was that transmissions that should have been 8-bit bytes appeared as 9-bit causing failed communication with SPI devices.
--- drivers/spi/spi-imx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-imx.c +2 -2
@@ -668,8 +668,8 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx, ctrl |= (MX51_ECSPI_CTRL_MAX_BURST *BITS_PER_BYTE -1 ) <<MX51_ECSPI_CTRL_BL_OFFSET ; else - ctrl |= spi_imx->count / DIV_ROUND_UP(spi_imx->bits_per_word, - BITS_PER_BYTE) * spi_imx->bits_per_word + ctrl |= (spi_imx->count / DIV_ROUND_UP(spi_imx->bits_per_word, + BITS_PER_BYTE) * spi_imx->bits_per_word - 1) << MX51_ECSPI_CTRL_BL_OFFSET; } }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 676/713 drm: Fix drm_fixp2int_round() making it add 0.5
In reply to Sasha LevinFrom: Arthur Grillo <[email protected]>
[ Upstream commit 807f96abdf14c80f534c78f2d854c2590963345c ]
As well noted by Pekka[1], the rounding of drm_fixp2int_round is wrong. To round a number, you need to add 0.5 to the number and floor that, drm_fixp2int_round() is adding 0.0000076. Make it add 0.5.
[1]: https://lore.kernel.org/all/[email protected]/
--- include/drm/drm_fixed.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/drm/drm_fixed.h +1 -2
@@ -71,7 +71,6 @@ static inline u32 dfixed_div(fixed20_12 A, fixed20_12 B) }#define DRM_FIXED_POINT 32 -#define DRM_FIXED_POINT_HALF 16#define DRM_FIXED_ONE (1ULL << DRM_FIXED_POINT)#define DRM_FIXED_DECIMAL_MASK (DRM_FIXED_ONE - 1)#define DRM_FIXED_DIGITS_MASK (~DRM_FIXED_DECIMAL_MASK)
@@ -90,7 +89,7 @@ static inline int drm_fixp2int(s64 a)static inline int drm_fixp2int_round (s64 a) { -return drm_fixp2int (a + (1 << (DRM_FIXED_POINT_HALF -1 ))); +return drm_fixp2int (a +DRM_FIXED_ONE /2 ); }static inline int drm_fixp2int_ceil (s64 a)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 677/713 vdpa_sim: reset must not run
In reply to Sasha LevinFrom: Steve Sistare <[email protected]>
[ Upstream commit 9588e7fc511f9c55b9835f14916e90ab940061b7 ]
vdpasim_do_reset sets running to true, which is wrong, as it allows vdpasim_kick_vq to post work requests before the device has been configured. To fix, do not set running until VIRTIO_CONFIG_S_DRIVER_OK is set.
Message-Id: <[email protected]>
--- drivers/vdpa/vdpa_sim/vdpa_sim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/vdpa/vdpa_sim/vdpa_sim.c +2 -1
@@ -160,7 +160,7 @@ static void vdpasim_do_reset(struct vdpasim *vdpasim, u32 flags) } } - vdpasim->running = true; + vdpasim->running = false;spin_unlock (&vdpasim->iommu_lock); vdpasim->features =0 ;
@@ -483,6 +483,7 @@ static void vdpasim_set_status(struct vdpa_device *vdpa, u8 status)mutex_lock (&vdpasim->mutex); vdpasim->status = status; + vdpasim->running = (status &VIRTIO_CONFIG_S_DRIVER_OK ) !=0 ;mutex_unlock (&vdpasim->mutex); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 678/713 vdpa/mlx5: Allow CVQ size changes
In reply to Sasha LevinFrom: Jonah Palmer <[email protected]>
[ Upstream commit 749a4016839270163efc36ecddddd01de491a16b ]
The MLX driver was not updating its control virtqueue size at set_vq_num and instead always initialized to MLX5_CVQ_MAX_ENT (16) at setup_cvq_vring.
Qemu would try to set the size to 64 by default, however, because the CVQ size always was initialized to 16, an error would be thrown when sending >16 control messages (as used-ring entry 17 is initialized to 0). For example, starting a guest with x-svq=on and then executing the following command would produce the error below:
# for i in {1..20}; do ifconfig eth0 hw ether XX:xx:XX:xx:XX:XX; doneqemu-system-x86_64: Insufficient written data (0)
[ 435.331223] virtio_net virtio0: Failed to set mac address by vq command. SIOCSIFHWADDR: Invalid argument
Message-Id: <[email protected]>
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +9 -4
@@ -145,8 +145,6 @@ static void teardown_driver(struct mlx5_vdpa_net *ndev);static bool mlx5_vdpa_debug; -#define MLX5_CVQ_MAX_ENT 16 -#define MLX5_LOG_VIO_FLAG (_feature) \ do { \ if (features & BIT_ULL(_feature)) \
@@ -2147,9 +2145,16 @@ static void mlx5_vdpa_set_vq_num(struct vdpa_device *vdev, u16 idx, u32 num)struct mlx5_vdpa_net *ndev =to_mlx5_vdpa_ndev (mvdev);struct mlx5_vdpa_virtqueue *mvq; -if (!is_index_valid (mvdev, idx) ||is_ctrl_vq_idx (mvdev, idx)) +if (!is_index_valid (mvdev, idx))return ; +if (is_ctrl_vq_idx (mvdev, idx)) { +struct mlx5_control_vq *cvq = &mvdev->cvq; + + cvq->vring.vring.num = num; +return ; + } + mvq = &ndev->vqs[idx]; mvq->num_ent = num; }
@@ -2819,7 +2824,7 @@ static int setup_cvq_vring(struct mlx5_vdpa_dev *mvdev)u16 idx = cvq->vring.last_avail_idx; err =vringh_init_iotlb (&cvq->vring, mvdev->actual_features, -MLX5_CVQ_MAX_ENT , false, + cvq->vring.vring.num, false, (struct vring_desc *)(uintptr_t )cvq->desc_addr, (struct vring_avail *)(uintptr_t )cvq->driver_addr, (struct vring_used *)(uintptr_t )cvq->device_addr);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 679/713 virtio: packed: fix unmap leak for indirect desc table
In reply to Sasha LevinFrom: Xuan Zhuo <[email protected]>
[ Upstream commit d5c0ed17fea60cca9bc3bf1278b49ba79242bbcd ]
When use_dma_api and premapped are true, then the do_unmap is false.
Because the do_unmap is false, vring_unmap_extra_packed is not called by detach_buf_packed.
if (unlikely(vq->do_unmap)) {
curr = id;
for (i = 0; i < state->num; i++) {
vring_unmap_extra_packed(vq,
&vq->packed.desc_extra[curr]);
curr = vq->packed.desc_extra[curr].next;
}
}So the indirect desc table is not unmapped. This causes the unmap leak.
So here, we check vq->use_dma_api instead. Synchronously, dma info is updated based on use_dma_api judgment
This bug does not occur, because no driver use the premapped with indirect.
Message-Id: <[email protected]>
--- drivers/virtio/virtio_ring.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/virtio/virtio_ring.c +3 -3
@@ -1340,7 +1340,7 @@ static int virtqueue_add_indirect_packed(struct vring_virtqueue *vq, sizeof(struct vring_packed_desc)); vq->packed.vring.desc[head].id =cpu_to_le16 (id); -if (vq->do_unmap) { +if (vq->use_dma_api) { vq->packed.desc_extra[id].addr = addr; vq->packed.desc_extra[id].len = total_sg *sizeof (struct vring_packed_desc );
@@ -1481,7 +1481,7 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq, desc[i].len =cpu_to_le32 (sg->length); desc[i].id =cpu_to_le16 (id); -if (unlikely (vq->do_unmap)) { +if (unlikely (vq->use_dma_api)) { vq->packed.desc_extra[curr].addr = addr; vq->packed.desc_extra[curr].len = sg->length; vq->packed.desc_extra[curr].flags =
@@ -1615,7 +1615,7 @@ static void detach_buf_packed(struct vring_virtqueue *vq, vq->free_head = id; vq->vq.num_free += state->num; -if (unlikely (vq->do_unmap)) { +if (unlikely (vq->use_dma_api)) { curr = id;for (i =0 ; i < state->num; i++) { vring_unmap_extra_packed(vq,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 680/713 wireguard: receive: annotate data-race around receiving_counter.counter
In reply to Sasha LevinFrom: Nikita Zhandarovich <[email protected]>
[ Upstream commit bba045dc4d996d03dce6fe45726e78a1a1f6d4c3 ]
Syzkaller with KCSAN identified a data-race issue when accessing keypair->receiving_counter.counter. Use READ_ONCE() and WRITE_ONCE() annotations to mark the data race as intentional.
BUG: KCSAN: data-race in wg_packet_decrypt_worker / wg_packet_rx_poll
write to 0xffff888107765888 of 8 bytes by interrupt on cpu 0:
counter_validate drivers/net/wireguard/receive.c:321 [inline]
wg_packet_rx_poll+0x3ac/0xf00 drivers/net/wireguard/receive.c:461
__napi_poll+0x60/0x3b0 net/core/dev.c:6536
napi_poll net/core/dev.c:6605 [inline]
net_rx_action+0x32b/0x750 net/core/dev.c:6738
__do_softirq+0xc4/0x279 kernel/softirq.c:553
do_softirq+0x5e/0x90 kernel/softirq.c:454
__local_bh_enable_ip+0x64/0x70 kernel/softirq.c:381
__raw_spin_unlock_bh include/linux/spinlock_api_smp.h:167 [inline]
_raw_spin_unlock_bh+0x36/0x40 kernel/locking/spinlock.c:210
spin_unlock_bh include/linux/spinlock.h:396 [inline]
ptr_ring_consume_bh include/linux/ptr_ring.h:367 [inline]
wg_packet_decrypt_worker+0x6c5/0x700 drivers/net/wireguard/receive.c:499
process_one_work kernel/workqueue.c:2633 [inline]
...
read to 0xffff888107765888 of 8 bytes by task 3196 on cpu 1:
decrypt_packet drivers/net/wireguard/receive.c:252 [inline]
wg_packet_decrypt_worker+0x220/0x700 drivers/net/wireguard/receive.c:501
process_one_work kernel/workqueue.c:2633 [inline]
process_scheduled_works+0x5b8/0xa30 kernel/workqueue.c:2706
worker_thread+0x525/0x730 kernel/workqueue.c:2787
...--- drivers/net/wireguard/receive.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireguard/receive.c +3 -3
@@ -251,7 +251,7 @@ static bool decrypt_packet(struct sk_buff *skb, struct noise_keypair *keypair)if (unlikely (!READ_ONCE (keypair->receiving.is_valid) ||wg_birthdate_has_expired (keypair->receiving.birthdate,REJECT_AFTER_TIME ) || - keypair->receiving_counter.counter >=REJECT_AFTER_MESSAGES )) { +READ_ONCE (keypair->receiving_counter.counter) >=REJECT_AFTER_MESSAGES )) {WRITE_ONCE (keypair->receiving.is_valid, false);return false; }
@@ -318,7 +318,7 @@ static bool counter_validate(struct noise_replay_counter *counter, u64 their_coufor (i =1 ; i <= top; ++i) counter->backtrack[(i + index_current) & ((COUNTER_BITS_TOTAL /BITS_PER_LONG ) -1 )] =0 ; - counter->counter = their_counter; +WRITE_ONCE (counter->counter, their_counter); } index &= (COUNTER_BITS_TOTAL /BITS_PER_LONG ) -1 ;
@@ -463,7 +463,7 @@ int wg_packet_rx_poll(struct napi_struct *napi, int budget)net_dbg_ratelimited ("%s: Packet has invalid nonce %llu (max %llu)\n" , peer->device->dev->name,PACKET_CB (skb)->nonce, - keypair->receiving_counter.counter); +READ_ONCE (keypair->receiving_counter.counter)); goto next; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 681/713 rds: introduce acquire/release ordering in acquire/release_in_xmit()
In reply to Sasha LevinFrom: Yewon Choi <[email protected]>
[ Upstream commit 1422f28826d2a0c11e5240b3e951c9e214d8656e ]
acquire/release_in_xmit() work as bit lock in rds_send_xmit(), so they are expected to ensure acquire/release memory ordering semantics. However, test_and_set_bit/clear_bit() don't imply such semantics, on top of this, following smp_mb__after_atomic() does not guarantee release ordering (memory barrier actually should be placed before clear_bit()).
Instead, we use clear_bit_unlock/test_and_set_bit_lock() here.
--- net/rds/send.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/rds/send.c +2 -3
@@ -103,13 +103,12 @@ EXPORT_SYMBOL_GPL(rds_send_path_reset);static int acquire_in_xmit (struct rds_conn_path *cp) { -return test_and_set_bit (RDS_IN_XMIT , &cp->cp_flags) ==0 ; +return test_and_set_bit_lock (RDS_IN_XMIT , &cp->cp_flags) ==0 ; }static void release_in_xmit (struct rds_conn_path *cp) { -clear_bit (RDS_IN_XMIT , &cp->cp_flags); -smp_mb__after_atomic (); +clear_bit_unlock (RDS_IN_XMIT , &cp->cp_flags);/* * We don't use wait_on_bit()/wake_up_bit() because our waking is in a * hot path and finding waiters is very rare. We don't want to walk
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 682/713 hsr: Handle failures in module init
In reply to Sasha LevinFrom: Felix Maurer <[email protected]>
[ Upstream commit 3cf28cd492308e5f63ed00b29ea03ca016264376 ]
A failure during registration of the netdev notifier was not handled at all. A failure during netlink initialization did not unregister the netdev notifier.
Handle failures of netdev notifier registration and netlink initialization. Both functions should only return negative values on failure and thereby lead to the hsr module not being loaded.
--- net/hsr/hsr_main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
net/hsr/hsr_main.c +11 -4
@@ -148,14 +148,21 @@ static struct notifier_block hsr_nb = {static int __init hsr_init (void ) { -int res; +int err;BUILD_BUG_ON (sizeof (struct hsr_tag ) !=HSR_HLEN ); -register_netdevice_notifier (&hsr_nb); - res =hsr_netlink_init (); + err =register_netdevice_notifier (&hsr_nb); +if (err) +return err; + + err =hsr_netlink_init (); +if (err) { +unregister_netdevice_notifier (&hsr_nb); +return err; + } -return res; +return 0 ; } static void __exit hsr_exit(void)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 683/713 ipv4: raw: Fix sending packets from raw sockets via IPsec tunnels
In reply to Sasha LevinFrom: Tobias Brunner <[email protected]>
[ Upstream commit c9b3b81716c5b92132a6c1d4ac3c48a7b44082ab ]
Since the referenced commit, the xfrm_inner_extract_output() function uses the protocol field to determine the address family. So not setting it for IPv4 raw sockets meant that such packets couldn't be tunneled via IPsec anymore.
IPv6 raw sockets are not affected as they already set the protocol since 9c9c9ad5fae7 ("ipv6: set skb->protocol on tcp, raw and ip6_append_data genereated skbs").
--- net/ipv4/raw.c | 1 + 1 file changed, 1 insertion(+)
net/ipv4/raw.c +1 -0
@@ -350,6 +350,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4, goto error;skb_reserve (skb, hlen); + skb->protocol =htons (ETH_P_IP ); skb->priority =READ_ONCE (sk->sk_priority); skb->mark = sockc->mark; skb->tstamp = sockc->transmit_time;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 684/713 nouveau/gsp: don't check devinit disable on GSP.
In reply to Sasha LevinFrom: Dave Airlie <[email protected]>
[ Upstream commit 5d4e8ae6e57b025802aadf55a4775c55cceb75f1 ]
GSP should be handling this and I can see no evidence in opengpu driver that this register should be touched.
Fixed acceleration on 2080 Ti GPUs.
--- drivers/gpu/drm/nouveau/nvkm/subdev/devinit/r535.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/subdev/devinit/r535.c +0 -1
@@ -41,7 +41,6 @@ r535_devinit_new(const struct nvkm_devinit_func *hw, rm->dtor = r535_devinit_dtor; rm->post = hw->post; - rm->disable = hw->disable; ret =nv50_devinit_new_ (rm, device, type, inst, pdevinit);if (ret)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 685/713 ceph: stop copying to iter at EOF on sync reads
In reply to Sasha LevinFrom: Xiubo Li <[email protected]>
[ Upstream commit 1065da21e5df9d843d2c5165d5d576be000142a6 ]
If EOF is encountered, ceph_sync_read() return value is adjusted down according to i_size, but the "to" iter is advanced by the actual number of bytes read. Then, when retrying, the remainder of the range may be skipped incorrectly.
Ensure that the "to" iter is advanced only until EOF.
[ idryomov: changelog ]
--- fs/ceph/file.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
fs/ceph/file.c +13 -10
@@ -1135,7 +1135,12 @@ ssize_t __ceph_sync_read(struct inode *inode, loff_t *ki_pos, } idx =0 ; - left = ret >0 ? ret :0 ; +if (ret <=0 ) + left =0 ; +else if (off + ret > i_size) + left = i_size - off; +else + left = ret;while (left >0 ) {size_t plen, copied;
@@ -1164,15 +1169,13 @@ ssize_t __ceph_sync_read(struct inode *inode, loff_t *ki_pos, }if (ret >0 ) { -if (off > *ki_pos) { -if (off >= i_size) { - *retry_op =CHECK_EOF ; - ret = i_size - *ki_pos; - *ki_pos = i_size; - }else { - ret = off - *ki_pos; - *ki_pos = off; - } +if (off >= i_size) { + *retry_op =CHECK_EOF ; + ret = i_size - *ki_pos; + *ki_pos = i_size; + }else { + ret = off - *ki_pos; + *ki_pos = off; }if (last_objver)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 686/713 net: phy: fix phy_read_poll_timeout argument type in genphy_loopback
In reply to Sasha LevinFrom: Nikita Kiryushin <[email protected]>
[ Upstream commit 32fa4366cc4da1c97b725a0066adf43c6b298f37 ]
read_poll_timeout inside phy_read_poll_timeout can set val negative in some cases (for example, __mdiobus_read inside phy_read can return -EOPNOTSUPP).
Supposedly, commit 4ec732951702 ("net: phylib: fix phy_read*_poll_timeout()") should fix problems with wrong-signed vals, but I do not see how as val is sent to phy_read as is and __val = phy_read (not val) is checked for sign.
Change val type for signed to allow better error handling as done in other phy_read_poll_timeout callers. This will not fix any error handling by itself, but allows, for example, to modify cond with appropriate sign check or check resulting val separately.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/phy/phy_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/phy_device.c +2 -2
@@ -2701,8 +2701,8 @@ EXPORT_SYMBOL(genphy_resume);int genphy_loopback (struct phy_device *phydev,bool enable) {if (enable) { -u16 val, ctl =BMCR_LOOPBACK ; -int ret; +u16 ctl =BMCR_LOOPBACK ; +int ret, val; ctl |=mii_bmcr_encode_fixed (phydev->speed, phydev->duplex);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 687/713 dm-integrity: fix a memory leak when rechecking the data
In reply to Sasha LevinFrom: Mikulas Patocka <[email protected]>
[ Upstream commit 55e565c42dce81a4e49c13262d5bc4eb4c2e588a ]
Memory for the "checksums" pointer will leak if the data is rechecked after checksum failure (because the associated kfree won't happen due to 'goto skip_io').
Fix this by freeing the checksums memory before recheck, and just use the "checksum_onstack" memory for storing checksum during recheck.
--- drivers/md/dm-integrity.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/md/dm-integrity.c +3 -3
@@ -1848,12 +1848,12 @@ static void integrity_metadata(struct work_struct *w) r =dm_integrity_rw_tag (ic, checksums, &dio->metadata_block, &dio->metadata_offset, checksums_ptr - checksums, dio->op ==REQ_OP_READ ?TAG_CMP :TAG_WRITE );if (unlikely (r)) { +if (likely (checksums != checksums_onstack)) +kfree (checksums);if (r >0 ) { -integrity_recheck (dio, checksums); +integrity_recheck (dio, checksums_onstack); goto skip_io; } -if (likely (checksums != checksums_onstack)) -kfree (checksums); goto error; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 688/713 net/bnx2x: Prevent access to a freed page in page_pool
In reply to Sasha LevinFrom: Thinh Tran <[email protected]>
[ Upstream commit d27e2da94a42655861ca4baea30c8cd65546f25d ]
Fix race condition leading to system crash during EEH error handling
During EEH error recovery, the bnx2x driver's transmit timeout logic could cause a race condition when handling reset tasks. The bnx2x_tx_timeout() schedules reset tasks via bnx2x_sp_rtnl_task(), which ultimately leads to bnx2x_nic_unload(). In bnx2x_nic_unload() SGEs are freed using bnx2x_free_rx_sge_range(). However, this could overlap with the EEH driver's attempt to reset the device using bnx2x_io_slot_reset(), which also tries to free SGEs. This race condition can result in system crashes due to accessing freed memory locations in bnx2x_free_rx_sge()
799 static inline void bnx2x_free_rx_sge(struct bnx2x *bp,
800 struct bnx2x_fastpath *fp, u16 index)
801 {
802 struct sw_rx_page *sw_buf = &fp->rx_page_ring[index];
803 struct page *page = sw_buf->page;
....
where sw_buf was set to NULL after the call to dma_unmap_page() by the preceding thread.
EEH: Beginning: 'slot_reset'
PCI 0011:01:00.0#10000: EEH: Invoking bnx2x->slot_reset()
bnx2x: [bnx2x_io_slot_reset:14228(eth1)]IO slot reset initializing...
bnx2x 0011:01:00.0: enabling device (0140 -> 0142)
bnx2x: [bnx2x_io_slot_reset:14244(eth1)]IO slot reset --> driver unload
Kernel attempted to read user page (0) - exploit attempt? (uid: 0)
BUG: Kernel NULL pointer dereference on read at 0x00000000
Faulting instruction address: 0xc0080000025065fc
Oops: Kernel access of bad area, sig: 11 [#1]
.....
Call Trace:
[c000000003c67a20] [c00800000250658c] bnx2x_io_slot_reset+0x204/0x610 [bnx2x] (unreliable)
[c000000003c67af0] [c0000000000518a8] eeh_report_reset+0xb8/0xf0
[c000000003c67b60] [c000000000052130] eeh_pe_report+0x180/0x550
[c000000003c67c70] [c00000000005318c] eeh_handle_normal_event+0x84c/0xa60
[c000000003c67d50] [c000000000053a84] eeh_event_handler+0xf4/0x170
[c000000003c67da0] [c000000000194c58] kthread+0x1c8/0x1d0
[c000000003c67e10] [c00000000000cf64] ret_from_kernel_thread+0x5c/0x64To solve this issue, we need to verify page pool allocations before freeing.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +3 -3
@@ -1002,9 +1002,6 @@ static inline void bnx2x_set_fw_mac_addr(__le16 *fw_hi, __le16 *fw_mid,static inline void bnx2x_free_rx_mem_pool (struct bnx2x *bp,struct bnx2x_alloc_pool *pool) { -if (!pool->page) -return ; -put_page (pool->page); pool->page =NULL ;
@@ -1015,6 +1012,9 @@ static inline void bnx2x_free_rx_sge_range(struct bnx2x *bp, {int i; +if (!fp->page_pool.page) +return ; +if (fp->mode ==TPA_MODE_DISABLED )return ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 689/713 devlink: fix port new reply cmd type
In reply to Sasha LevinFrom: Jiri Pirko <[email protected]>
[ Upstream commit 78a2f5e6c15d8dcbd6495bb9635c7cb89235dfc5 ]
Due to a c&p error, port new reply fills-up cmd with wrong value, any other existing port command replies and notifications.
Fix it by filling cmd with value DEVLINK_CMD_PORT_NEW.
Skimmed through devlink userspace implementations, none of them cares about this cmd value.
--- net/devlink/port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/devlink/port.c +1 -1
@@ -887,7 +887,7 @@ int devlink_nl_port_new_doit(struct sk_buff *skb, struct genl_info *info) err = -ENOMEM ; goto err_out_port_del; } - err =devlink_nl_port_fill (msg, devlink_port,DEVLINK_CMD_NEW , + err =devlink_nl_port_fill (msg, devlink_port,DEVLINK_CMD_PORT_NEW , info->snd_portid, info->snd_seq,0 ,NULL );if (WARN_ON_ONCE (err)) goto err_out_msg_free;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 690/713 octeontx2: Detect the mbox up or down message via register
In reply to Sasha LevinFrom: Subbaraya Sundeep <[email protected]>
[ Upstream commit a88e0f936ba9a301c78f6eacfd38737d003c130b ]
A single line of interrupt is used to receive up notifications and down reply messages from AF to PF (similarly from PF to its VF). PF acts as bridge and forwards VF messages to AF and sends respsones back from AF to VF. When an async event like link event is received by up message when PF is in middle of forwarding VF message then mailbox errors occur because PF state machine is corrupted. Since VF is a separate driver or VF driver can be in a VM it is not possible to serialize from the start of communication at VF. Hence to differentiate between type of messages at PF this patch makes sender to set mbox data register with distinct values for up and down messages. Sender also checks whether previous interrupt is received before triggering current interrupt by waiting for mailbox data register to become zero.
--- .../net/ethernet/marvell/octeontx2/af/mbox.c | 43 ++++++- .../net/ethernet/marvell/octeontx2/af/mbox.h | 6 + .../marvell/octeontx2/af/mcs_rvu_if.c | 17 ++- .../net/ethernet/marvell/octeontx2/af/rvu.c | 14 ++- .../net/ethernet/marvell/octeontx2/af/rvu.h | 2 + .../ethernet/marvell/octeontx2/af/rvu_cgx.c | 20 ++-- .../marvell/octeontx2/nic/otx2_common.h | 2 +- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 113 ++++++++++++------ .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 71 ++++++----- 9 files changed, 205 insertions(+), 83 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.c +41 -2
@@ -214,11 +214,12 @@ int otx2_mbox_busy_poll_for_rsp(struct otx2_mbox *mbox, int devid) }EXPORT_SYMBOL (otx2_mbox_busy_poll_for_rsp); -void otx2_mbox_msg_send (struct otx2_mbox *mbox,int devid) +static void otx2_mbox_msg_send_data (struct otx2_mbox *mbox,int devid,u64 data) {struct otx2_mbox_dev *mdev = &mbox->dev[devid];struct mbox_hdr *tx_hdr, *rx_hdr;void *hw_mbase = mdev->hwbase; +u64 intr_val; tx_hdr = hw_mbase + mbox->tx_start; rx_hdr = hw_mbase + mbox->rx_start;
@@ -254,14 +255,52 @@ void otx2_mbox_msg_send(struct otx2_mbox *mbox, int devid)spin_unlock (&mdev->mbox_lock); +/* Check if interrupt pending */ + intr_val =readq ((void __iomem *)mbox->reg_base + + (mbox->trigger | (devid << mbox->tr_shift))); + + intr_val |= data;/* The interrupt should be fired after num_msgs is written * to the shared memory */ -writeq (1 , (void __iomem *)mbox->reg_base + +writeq (intr_val, (void __iomem *)mbox->reg_base + (mbox->trigger | (devid << mbox->tr_shift))); } + +void otx2_mbox_msg_send (struct otx2_mbox *mbox,int devid) +{ +otx2_mbox_msg_send_data (mbox, devid,MBOX_DOWN_MSG ); +}EXPORT_SYMBOL (otx2_mbox_msg_send); +void otx2_mbox_msg_send_up (struct otx2_mbox *mbox,int devid) +{ +otx2_mbox_msg_send_data (mbox, devid,MBOX_UP_MSG ); +} +EXPORT_SYMBOL (otx2_mbox_msg_send_up); + +bool otx2_mbox_wait_for_zero (struct otx2_mbox *mbox,int devid) +{ +u64 data; + + data =readq ((void __iomem *)mbox->reg_base + + (mbox->trigger | (devid << mbox->tr_shift))); + +/* If data is non-zero wait for ~1ms and return to caller +* whether data has changed to zero or not after the wait. +*/ +if (!data) +return true; + +usleep_range (950 ,1000 ); + + data =readq ((void __iomem *)mbox->reg_base + + (mbox->trigger | (devid << mbox->tr_shift))); + +return data ==0 ; +} +EXPORT_SYMBOL (otx2_mbox_wait_for_zero); +struct mbox_msghdr *otx2_mbox_alloc_msg_rsp (struct otx2_mbox *mbox,int devid,int size,int size_rsp) {
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +6 -0
@@ -16,6 +16,9 @@#define MBOX_SIZE SZ_64K +#define MBOX_DOWN_MSG 1 +#define MBOX_UP_MSG 2 +/* AF/PF: PF initiated, PF/VF VF initiated */ #define MBOX_DOWN_RX_START 0#define MBOX_DOWN_RX_SIZE (46 * SZ_1K)
@@ -101,6 +104,7 @@ int otx2_mbox_regions_init(struct otx2_mbox *mbox, void __force **hwbase, struct pci_dev *pdev, void __force *reg_base, int direction, int ndevs, unsigned long *bmap);void otx2_mbox_msg_send (struct otx2_mbox *mbox,int devid); +void otx2_mbox_msg_send_up (struct otx2_mbox *mbox,int devid);int otx2_mbox_wait_for_rsp (struct otx2_mbox *mbox,int devid);int otx2_mbox_busy_poll_for_rsp (struct otx2_mbox *mbox,int devid); struct mbox_msghdr *otx2_mbox_alloc_msg_rsp(struct otx2_mbox *mbox, int devid,
@@ -118,6 +122,8 @@ static inline struct mbox_msghdr *otx2_mbox_alloc_msg(struct otx2_mbox *mbox,return otx2_mbox_alloc_msg_rsp (mbox, devid, size,0 ); } +bool otx2_mbox_wait_for_zero (struct otx2_mbox *mbox,int devid); +/* Mailbox message types */ #define MBOX_MSG_MASK 0xFFFF#define MBOX_MSG_INVALID 0xFFFE
drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c +11 -6
@@ -121,13 +121,17 @@ int mcs_add_intr_wq_entry(struct mcs *mcs, struct mcs_intr_event *event)static int mcs_notify_pfvf (struct mcs_intr_event *event,struct rvu *rvu) {struct mcs_intr_info *req; -int err, pf; +int pf; pf =rvu_get_pf (event->pcifunc); +mutex_lock (&rvu->mbox_lock); + req =otx2_mbox_alloc_msg_mcs_intr_notify (rvu, pf); -if (!req) +if (!req) { +mutex_unlock (&rvu->mbox_lock);return -ENOMEM ; + } req->mcs_id = event->mcs_id; req->intr_mask = event->intr_mask;
@@ -135,10 +139,11 @@ static int mcs_notify_pfvf(struct mcs_intr_event *event, struct rvu *rvu) req->hdr.pcifunc = event->pcifunc; req->lmac_id = event->lmac_id; -otx2_mbox_msg_send (&rvu->afpf_wq_info.mbox_up, pf); - err =otx2_mbox_wait_for_rsp (&rvu->afpf_wq_info.mbox_up, pf); -if (err) -dev_warn (rvu->dev,"MCS notification to pf %d failed\n" , pf); +otx2_mbox_wait_for_zero (&rvu->afpf_wq_info.mbox_up, pf); + +otx2_mbox_msg_send_up (&rvu->afpf_wq_info.mbox_up, pf); + +mutex_unlock (&rvu->mbox_lock);return 0 ; }
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +11 -3
@@ -2114,7 +2114,7 @@ MBOX_MESSAGES } } -static void __rvu_mbox_handler (struct rvu_work *mwork,int type) +static void __rvu_mbox_handler (struct rvu_work *mwork,int type,bool poll) {struct rvu *rvu = mwork->rvu;int offset, err, id, devid;
@@ -2181,6 +2181,9 @@ static void __rvu_mbox_handler(struct rvu_work *mwork, int type) } mw->mbox_wrk[devid].num_msgs =0 ; +if (poll) +otx2_mbox_wait_for_zero (mbox, devid); +/* Send mbox responses to VF/PF */ otx2_mbox_msg_send (mbox, devid); }
@@ -2188,15 +2191,18 @@ static void __rvu_mbox_handler(struct rvu_work *mwork, int type)static inline void rvu_afpf_mbox_handler (struct work_struct *work) { struct rvu_work *mwork = container_of(work, struct rvu_work, work); +struct rvu *rvu = mwork->rvu; -__rvu_mbox_handler (mwork,TYPE_AFPF ); +mutex_lock (&rvu->mbox_lock); +__rvu_mbox_handler (mwork,TYPE_AFPF , true); +mutex_unlock (&rvu->mbox_lock); }static inline void rvu_afvf_mbox_handler (struct work_struct *work) { struct rvu_work *mwork = container_of(work, struct rvu_work, work); -__rvu_mbox_handler (mwork,TYPE_AFVF ); +__rvu_mbox_handler (mwork,TYPE_AFVF , false); }static void __rvu_mbox_up_handler (struct rvu_work *mwork,int type)
@@ -2371,6 +2377,8 @@ static int rvu_mbox_init(struct rvu *rvu, struct mbox_wq_info *mw, } } +mutex_init (&rvu->mbox_lock); + mbox_regions =kcalloc (num,sizeof (void *),GFP_KERNEL );if (!mbox_regions) { err = -ENOMEM ;
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +2 -0
@@ -551,6 +551,8 @@ struct rvu {spinlock_t mcs_intrq_lock;/* CPT interrupt lock */ spinlock_t cpt_intr_lock; + +struct mutex mbox_lock;/* Serialize mbox up and down msgs */ };static inline void rvu_write64 (struct rvu *rvu,u64 block,u64 offset,u64 val)
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +13 -7
@@ -232,7 +232,7 @@ static void cgx_notify_pfs(struct cgx_link_event *event, struct rvu *rvu)struct cgx_link_user_info *linfo;struct cgx_link_info_msg *msg;unsigned long pfmap; -int err, pfid; +int pfid; linfo = &event->link_uinfo; pfmap =cgxlmac_to_pfmap (rvu, event->cgx_id, event->lmac_id);
@@ -255,16 +255,22 @@ static void cgx_notify_pfs(struct cgx_link_event *event, struct rvu *rvu)continue ; } +mutex_lock (&rvu->mbox_lock); +/* Send mbox message to PF */ msg =otx2_mbox_alloc_msg_cgx_link_event (rvu, pfid); -if (!msg) +if (!msg) { +mutex_unlock (&rvu->mbox_lock);continue ; + } + msg->link_info = *linfo; -otx2_mbox_msg_send (&rvu->afpf_wq_info.mbox_up, pfid); - err =otx2_mbox_wait_for_rsp (&rvu->afpf_wq_info.mbox_up, pfid); -if (err) -dev_warn (rvu->dev,"notification to pf %d failed\n" , - pfid); + +otx2_mbox_wait_for_zero (&rvu->afpf_wq_info.mbox_up, pfid); + +otx2_mbox_msg_send_up (&rvu->afpf_wq_info.mbox_up, pfid); + +mutex_unlock (&rvu->mbox_lock); }while (pfmap); }
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +1 -1
@@ -815,7 +815,7 @@ static inline int otx2_sync_mbox_up_msg(struct mbox *mbox, int devid)if (!otx2_mbox_nonempty (&mbox->mbox_up, devid))return 0 ; -otx2_mbox_msg_send (&mbox->mbox_up, devid); +otx2_mbox_msg_send_up (&mbox->mbox_up, devid); err =otx2_mbox_wait_for_rsp (&mbox->mbox_up, devid);if (err)return err;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +77 -36
236 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +43 -28
117 lines not on this page · raw message
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 691/713 octeontx2-pf: Wait till detach_resources msg is complete
In reply to Sasha LevinFrom: Subbaraya Sundeep <[email protected]>
[ Upstream commit cbf2f24939a5dafce6de4dd4422e543ce8f610cf ]
During VF driver remove, a message is sent to detach VF resources to PF but VF is not waiting until message is complete. Also mailbox interrupts need to be turned off after the detach resource message is complete. This patch fixes that problem.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 2 +- drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +1 -1
@@ -1592,7 +1592,7 @@ int otx2_detach_resources(struct mbox *mbox) detach->partial = false;/* Send detach request to AF */ -otx2_mbox_msg_send (&mbox->mbox,0 ); +otx2_sync_mbox_msg (mbox);mutex_unlock (&mbox->lock);return 0 ; }
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +1 -1
@@ -775,8 +775,8 @@ static void otx2vf_remove(struct pci_dev *pdev)otx2_mcam_flow_del (vf);otx2_shutdown_tc (vf);otx2_shutdown_qos (vf); -otx2vf_disable_mbox_intr (vf);otx2_detach_resources (&vf->mbox); +otx2vf_disable_mbox_intr (vf);free_percpu (vf->hw.lmt_info);if (test_bit (CN10K_LMTST , &vf->hw.cap_flag))qmem_free (vf->dev, vf->dync_lmt);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 692/713 octeontx2-pf: Use default max_active works instead of one
In reply to Sasha LevinFrom: Subbaraya Sundeep <[email protected]>
[ Upstream commit 7558ce0d974ced1dc07edc1197f750fe28c52e57 ]
Only one execution context for the workqueue used for PF and VFs mailbox communication is incorrect since multiple works are queued simultaneously by all the VFs and PF link UP messages. Hence use default number of execution contexts by passing zero as max_active to alloc_workqueue function. With this fix in place, modify UP messages also to wait until completion.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +4 -3
@@ -584,8 +584,9 @@ static int otx2_pfvf_mbox_init(struct otx2_nic *pf, int numvfs)if (!pf->mbox_pfvf)return -ENOMEM ; - pf->mbox_pfvf_wq =alloc_ordered_workqueue ("otx2_pfvf_mailbox" , -WQ_HIGHPRI |WQ_MEM_RECLAIM ); + pf->mbox_pfvf_wq =alloc_workqueue ("otx2_pfvf_mailbox" , +WQ_UNBOUND |WQ_HIGHPRI | +WQ_MEM_RECLAIM ,0 );if (!pf->mbox_pfvf_wq)return -ENOMEM ;
@@ -3146,7 +3147,7 @@ static void otx2_vf_link_event_task(struct work_struct *work)otx2_mbox_wait_for_zero (&pf->mbox_pfvf[0 ].mbox_up, vf_idx); -otx2_mbox_msg_send_up (&pf->mbox_pfvf[0 ].mbox_up, vf_idx); +otx2_sync_mbox_up_msg (&pf->mbox_pfvf[0 ], vf_idx);mutex_unlock (&pf->mbox.lock); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 693/713 octeontx2-pf: Send UP messages to VF only when VF is up.
In reply to Sasha LevinFrom: Subbaraya Sundeep <[email protected]>
[ Upstream commit dfcf6355f53b1796cf7fd50a4f27b18ee6a3497a ]
When PF sending link status messages to VF, it is possible that by the time link_event_task work function is executed VF might have brought down. Hence before sending VF link status message check whether VF is up to receive it.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +3 -0
@@ -3122,6 +3122,9 @@ static void otx2_vf_link_event_task(struct work_struct *work) vf_idx = config - config->pf->vf_configs; pf = config->pf; +if (config->intf_down) +return ; +mutex_lock (&pf->mbox.lock); dwork = &config->link_event_work;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 694/713 octeontx2-af: Use separate handlers for interrupts
In reply to Sasha LevinFrom: Subbaraya Sundeep <[email protected]>
[ Upstream commit 50e60de381c342008c0956fd762e1c26408f372c ]
For PF to AF interrupt vector and VF to AF vector same interrupt handler is registered which is causing race condition. When two interrupts are raised to two CPUs at same time then two cores serve same event corrupting the data.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +14 -3
@@ -2528,10 +2528,9 @@ static void rvu_queue_work(struct mbox_wq_info *mw, int first, } } -static irqreturn_t rvu_mbox_intr_handler (int irq,void *rvu_irq) +static irqreturn_t rvu_mbox_pf_intr_handler (int irq,void *rvu_irq) {struct rvu *rvu = (struct rvu *)rvu_irq; -int vfs = rvu->vfs;u64 intr; intr =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_AF_PFAF_MBOX_INT );
@@ -2545,6 +2544,18 @@ static irqreturn_t rvu_mbox_intr_handler(int irq, void *rvu_irq)rvu_queue_work (&rvu->afpf_wq_info,0 , rvu->hw->total_pfs, intr); +return IRQ_HANDLED ; +} + +static irqreturn_t rvu_mbox_intr_handler (int irq,void *rvu_irq) +{ +struct rvu *rvu = (struct rvu *)rvu_irq; +int vfs = rvu->vfs; +u64 intr; + +/* Sync with mbox memory region */ +rmb (); +/* Handle VF interrupts */ if (vfs >64 ) { intr =rvupf_read64 (rvu,RVU_PF_VFPF_MBOX_INTX (1 ));
@@ -2882,7 +2893,7 @@ static int rvu_register_interrupts(struct rvu *rvu)/* Register mailbox interrupt handler */ sprintf (&rvu->irq_name[RVU_AF_INT_VEC_MBOX *NAME_SIZE ],"RVUAF Mbox" ); ret =request_irq (pci_irq_vector (rvu->pdev,RVU_AF_INT_VEC_MBOX ), - rvu_mbox_intr_handler,0 , + rvu_mbox_pf_intr_handler,0 , &rvu->irq_name[RVU_AF_INT_VEC_MBOX *NAME_SIZE ], rvu);if (ret) { dev_err(rvu->dev,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 695/713 drm/amdgpu: add MMHUB 3.3.1 support
In reply to Sasha LevinFrom: Yifan Zhang <[email protected]>
[ Upstream commit 31e0a586f3385134bcad00d8194eb0728cb1a17d ]
This patch to add MMHUB 3.3.1 support.
v2: squash in fault info fix (Alex)
Stable-dep-of: 6540ff6482c1 ("drm/amdgpu: fix mmhub client id out-of-bounds access")
--- drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 1 + drivers/gpu/drm/amd/amdgpu/mmhub_v3_3.c | 1 + 2 files changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1 -0
@@ -570,6 +570,7 @@ static void gmc_v11_0_set_mmhub_funcs(struct amdgpu_device *adev) adev->mmhub.funcs = &mmhub_v3_0_2_funcs;break ;case IP_VERSION (3 ,3 ,0 ): +case IP_VERSION (3 ,3 ,1 ): adev->mmhub.funcs = &mmhub_v3_3_funcs;break ;default :
drivers/gpu/drm/amd/amdgpu/mmhub_v3_3.c +1 -0
@@ -98,6 +98,7 @@ mmhub_v3_3_print_l2_protection_fault_status(struct amdgpu_device *adev,switch (amdgpu_ip_version (adev,MMHUB_HWIP ,0 )) {case IP_VERSION (3 ,3 ,0 ): +case IP_VERSION (3 ,3 ,1 ): mmhub_cid = mmhub_client_ids_v3_3[cid][rw];break ;default :
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 696/713 drm/amdgpu: fix mmhub client id out-of-bounds access
In reply to Sasha LevinFrom: Lang Yu <[email protected]>
[ Upstream commit 6540ff6482c1a5a6890ae44b23d0852ba1986d9e ]
Properly handle cid 0x140.
--- drivers/gpu/drm/amd/amdgpu/mmhub_v3_3.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/mmhub_v3_3.c +3 -4
@@ -99,16 +99,15 @@ mmhub_v3_3_print_l2_protection_fault_status(struct amdgpu_device *adev,switch (amdgpu_ip_version (adev,MMHUB_HWIP ,0 )) {case IP_VERSION (3 ,3 ,0 ):case IP_VERSION (3 ,3 ,1 ): - mmhub_cid = mmhub_client_ids_v3_3[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_v3_3) ? + mmhub_client_ids_v3_3[cid][rw] : + cid ==0x140 ?"UMSCH" :NULL ;break ;default : mmhub_cid =NULL ;break ; } -if (!mmhub_cid && cid ==0x140 ) - mmhub_cid ="UMSCH" ; -dev_err (adev->dev,"\t Faulty UTCL2 client ID: %s (0x%x)\n" , mmhub_cid ? mmhub_cid :"unknown" , cid); dev_err(adev->dev, "\t MORE_FAULTS: 0x%lx\n",
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 697/713 drm/amdgpu: drop setting buffer funcs in sdma442
In reply to Sasha LevinFrom: Le Ma <[email protected]>
[ Upstream commit ad550dbe8ae4ba833371a018265c1c3ae88559f0 ]
To fix the entity rq NULL issue. This setting has been moved to upper level.
--- drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +1 -22
@@ -429,16 +429,11 @@ static void sdma_v4_4_2_inst_gfx_stop(struct amdgpu_device *adev,struct amdgpu_ring *sdma[AMDGPU_MAX_SDMA_INSTANCES ];u32 doorbell_offset, doorbell;u32 rb_cntl, ib_cntl; -int i, unset =0 ; +int i;for_each_inst (i, inst_mask) { sdma[i] = &adev->sdma.instance[i].ring; -if ((adev->mman.buffer_funcs_ring == sdma[i]) && unset !=1 ) { -amdgpu_ttm_set_buffer_funcs_status (adev, false); - unset =1 ; - } - rb_cntl =RREG32_SDMA (i, regSDMA_GFX_RB_CNTL); rb_cntl =REG_SET_FIELD (rb_cntl,SDMA_GFX_RB_CNTL ,RB_ENABLE ,0 );WREG32_SDMA (i, regSDMA_GFX_RB_CNTL, rb_cntl);
@@ -485,20 +480,10 @@ static void sdma_v4_4_2_inst_rlc_stop(struct amdgpu_device *adev,static void sdma_v4_4_2_inst_page_stop (struct amdgpu_device *adev,uint32_t inst_mask) { -struct amdgpu_ring *sdma[AMDGPU_MAX_SDMA_INSTANCES ];u32 rb_cntl, ib_cntl;int i; -bool unset = false;for_each_inst (i, inst_mask) { - sdma[i] = &adev->sdma.instance[i].page; - -if ((adev->mman.buffer_funcs_ring == sdma[i]) && - (!unset)) { -amdgpu_ttm_set_buffer_funcs_status (adev, false); - unset = true; - } - rb_cntl =RREG32_SDMA (i, regSDMA_PAGE_RB_CNTL); rb_cntl =REG_SET_FIELD (rb_cntl,SDMA_PAGE_RB_CNTL ,RB_ENABLE ,0 );
@@ -948,13 +933,7 @@ static int sdma_v4_4_2_inst_start(struct amdgpu_device *adev, r =amdgpu_ring_test_helper (page);if (r)return r; - -if (adev->mman.buffer_funcs_ring == page) -amdgpu_ttm_set_buffer_funcs_status (adev, true); } - -if (adev->mman.buffer_funcs_ring == ring) -amdgpu_ttm_set_buffer_funcs_status (adev, true); }return r;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 698/713 riscv: Fix syscall wrapper for >word-size arguments
In reply to Sasha LevinFrom: Sami Tolvanen <[email protected]>
[ Upstream commit a9ad73295cc1e3af0253eee7d08943b2419444c4 ]
The current syscall wrapper macros break 64-bit arguments on rv32 because they only guarantee the first N input registers are passed to syscalls that accept N arguments. According to the calling convention, values twice the word size reside in register pairs and as a result, syscall arguments don't always have a direct register mapping on rv32.
Instead of using __MAP(x,__SC_LONG,__VA_ARGS__) to declare the type of the __se(_compat)_sys_* functions on rv32, change the function declarations to accept ulong arguments and alias them to the actual syscall implementations, similarly to the existing macros in include/linux/syscalls.h. This matches previous behavior and ensures registers are passed to syscalls as-is, no matter which argument types they expect.
--- arch/riscv/include/asm/syscall_wrapper.h | 53 +++++++++++++++++------- 1 file changed, 39 insertions(+), 14 deletions(-)
arch/riscv/include/asm/syscall_wrapper.h +39 -14
@@ -12,25 +12,51 @@asmlinkage long __riscv_sys_ni_syscall (const struct pt_regs *); -#define SC_RISCV_REGS_TO_ARGS (x, ...) \ - __MAP(x,__SC_ARGS \ - ,,regs->orig_a0,,regs->a1,,regs->a2 \ +#ifdef CONFIG_64BIT + +#define __SYSCALL_SE_DEFINEx (x, prefix, name, ...) \ + static long __se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ + static long __se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__)) + +#define SC_RISCV_REGS_TO_ARGS (x, ...) \ + __MAP(x,__SC_ARGS \ + ,,regs->orig_a0,,regs->a1,,regs->a2 \ ,,regs->a3,,regs->a4,,regs->a5,,regs->a6) +#else +/* +* Use type aliasing to ensure registers a0-a6 are correctly passed to the syscall +* implementation when >word-size arguments are used. +*/ +#define __SYSCALL_SE_DEFINEx (x, prefix, name, ...) \ + __diag_push(); \ + __diag_ignore(GCC, 8, "-Wattribute-alias", \ + "Type aliasing is used to sanitize syscall arguments"); \ + static long __se_##prefix##name(ulong, ulong, ulong, ulong, ulong, ulong, \ + ulong) \ + __attribute__((alias(__stringify(___se_##prefix##name)))); \ + __diag_pop(); \ + static long noinline ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ + static long ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__)) + +#define SC_RISCV_REGS_TO_ARGS (x, ...) \ + regs->orig_a0,regs->a1,regs->a2,regs->a3,regs->a4,regs->a5,regs->a6 + +#endif /* CONFIG_64BIT */ +#ifdef CONFIG_COMPAT #define COMPAT_SYSCALL_DEFINEx (x, name, ...) \ asmlinkage long __riscv_compat_sys##name(const struct pt_regs *regs); \ ALLOW_ERROR_INJECTION(__riscv_compat_sys##name, ERRNO); \ - static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ - asmlinkage long __riscv_compat_sys##name(const struct pt_regs *regs) \ + __SYSCALL_SE_DEFINEx(x, compat_sys, name, __VA_ARGS__) \ { \ - return __se_compat_sys##name(SC_RISCV_REGS_TO_ARGS(x,__VA_ARGS__)); \ + return __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \ } \ - static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ + asmlinkage long __riscv_compat_sys##name(const struct pt_regs *regs) \ { \ - return __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \ + return __se_compat_sys##name(SC_RISCV_REGS_TO_ARGS(x,__VA_ARGS__)); \ } \ static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
@@ -51,19 +77,18 @@ asmlinkage long __riscv_sys_ni_syscall(const struct pt_regs *);#define __SYSCALL_DEFINEx (x, name, ...) \ asmlinkage long __riscv_sys##name(const struct pt_regs *regs); \ ALLOW_ERROR_INJECTION(__riscv_sys##name, ERRNO); \ - static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ - asmlinkage long __riscv_sys##name(const struct pt_regs *regs) \ - { \ - return __se_sys##name(SC_RISCV_REGS_TO_ARGS(x,__VA_ARGS__)); \ - } \ - static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ + __SYSCALL_SE_DEFINEx(x, sys, name, __VA_ARGS__) \ { \ long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \ __MAP(x,__SC_TEST,__VA_ARGS__); \ __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \ return ret; \ } \ + asmlinkage long __riscv_sys##name(const struct pt_regs *regs) \ + { \ + return __se_sys##name(SC_RISCV_REGS_TO_ARGS(x,__VA_ARGS__)); \ + } \ static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))#define SYSCALL_DEFINE0 (sname) \
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 699/713 netfilter: nft_set_pipapo: release elements in clone only from destroy path
In reply to Sasha LevinFrom: Pablo Neira Ayuso <[email protected]>
[ Upstream commit b0e256f3dd2ba6532f37c5c22e07cb07a36031ee ]
Clone already always provides a current view of the lookup table, use it to destroy the set, otherwise it is possible to destroy elements twice.
This fix requires:
212ed75dc5fb ("netfilter: nf_tables: integrate pipapo into commit protocol")
which came after:
9827a0e6e23b ("netfilter: nft_set_pipapo: release elements in clone from abort path").
--- net/netfilter/nft_set_pipapo.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
net/netfilter/nft_set_pipapo.c +1 -4
@@ -2244,8 +2244,6 @@ static void nft_pipapo_destroy(const struct nft_ctx *ctx,if (m) {rcu_barrier (); -nft_set_pipapo_match_destroy (ctx, set, m); -for_each_possible_cpu (cpu)pipapo_free_scratch (m, cpu);free_percpu (m->scratch);
@@ -2257,8 +2255,7 @@ static void nft_pipapo_destroy(const struct nft_ctx *ctx,if (priv->clone) { m = priv->clone; -if (priv->dirty) -nft_set_pipapo_match_destroy (ctx, set, m); +nft_set_pipapo_match_destroy (ctx, set, m);for_each_possible_cpu (cpu)pipapo_free_scratch (priv->clone, cpu);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 700/713 netfilter: nf_tables: do not compare internal table flags on updates
In reply to Sasha LevinFrom: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 4a0e7f2decbf9bd72461226f1f5f7dcc4b08f139 ]
Restore skipping transaction if table update does not modify flags.
--- net/netfilter/nf_tables_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +1 -1
@@ -1211,7 +1211,7 @@ static int nf_tables_updtable(struct nft_ctx *ctx)if (flags & ~NFT_TABLE_F_MASK )return -EOPNOTSUPP ; -if (flags == ctx->table->flags) +if (flags == (ctx->table->flags &NFT_TABLE_F_MASK ))return 0 ; if ((nft_table_has_owner(ctx->table) &&
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 701/713 rcu: add a helper to report consolidated flavor QS
In reply to Sasha LevinFrom: Yan Zhai <[email protected]>
[ Upstream commit 1a77557d48cff187a169c2aec01c0dd78a5e7e50 ]
When under heavy load, network processing can run CPU-bound for many tens of seconds. Even in preemptible kernels (non-RT kernel), this can block RCU Tasks grace periods, which can cause trace-event removal to take more than a minute, which is unacceptably long.
This commit therefore creates a new helper function that passes through both RCU and RCU-Tasks quiescent states every 100 milliseconds. This hard-coded value suffices for current workloads.
Stable-dep-of: d6dbbb11247c ("net: report RCU QS on threaded NAPI repolling")
--- include/linux/rcupdate.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
include/linux/rcupdate.h +31 -0
@@ -250,6 +250,37 @@ do { \cond_resched (); \ }while (0 ) +/** +* rcu_softirq_qs_periodic - Report RCU and RCU-Tasks quiescent states +* @old_ts: jiffies at start of processing. +* +* This helper is for long-running softirq handlers, such as NAPI threads in +* networking. The caller should initialize the variable passed in as @old_ts +* at the beginning of the softirq handler. When invoked frequently, this macro +* will invoke rcu_softirq_qs() every 100 milliseconds thereafter, which will +* provide both RCU and RCU-Tasks quiescent states. Note that this macro +* modifies its old_ts argument. +* +* Because regions of code that have disabled softirq act as RCU read-side +* critical sections, this macro should be invoked with softirq (and +* preemption) enabled. +* +* The macro is not needed when CONFIG_PREEMPT_RT is defined. RT kernels would +* have more chance to invoke schedule() calls and provide necessary quiescent +* states. As a contrast, calling cond_resched() only won't achieve the same +* effect because cond_resched() does not provide RCU-Tasks quiescent states. + */ +#define rcu_softirq_qs_periodic (old_ts) \ +do { \ + if (!IS_ENABLED(CONFIG_PREEMPT_RT) && \ + time_after(jiffies, (old_ts) + HZ / 10)) { \ + preempt_disable(); \ + rcu_softirq_qs(); \ + preempt_enable(); \ + (old_ts) = jiffies; \ + } \ +} while (0) +/* * Infrastructure to implement the synchronize_() primitives in * TREE_RCU and rcu_barrier_() primitives in TINY_RCU.
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 702/713 net: report RCU QS on threaded NAPI repolling
In reply to Sasha LevinFrom: Yan Zhai <[email protected]>
[ Upstream commit d6dbbb11247c71203785a2c9da474c36f4b19eae ]
NAPI threads can keep polling packets under load. Currently it is only calling cond_resched() before repolling, but it is not sufficient to clear out the holdout of RCU tasks, which prevent BPF tracing programs from detaching for long period. This can be reproduced easily with following set up:
ip netns add test1
ip netns add test2
ip -n test1 link add veth1 type veth peer name veth2 netns test2
ip -n test1 link set veth1 up
ip -n test1 link set lo up
ip -n test2 link set veth2 up
ip -n test2 link set lo up
ip -n test1 addr add 192.168.1.2/31 dev veth1
ip -n test1 addr add 1.1.1.1/32 dev lo
ip -n test2 addr add 192.168.1.3/31 dev veth2
ip -n test2 addr add 2.2.2.2/31 dev lo
ip -n test1 route add default via 192.168.1.3
ip -n test2 route add default via 192.168.1.2
for i in seq 10 210; do
for j in seq 10 210; do
ip netns exec test2 iptables -I INPUT -s 3.3.$i.$j -p udp --dport 5201
done
done
ip netns exec test2 ethtool -K veth2 gro on
ip netns exec test2 bash -c 'echo 1 > /sys/class/net/veth2/threaded' ip netns exec test1 ethtool -K veth1 tso off
Then run an iperf3 client/server and a bpftrace script can trigger it:
ip netns exec test2 iperf3 -s -B 2.2.2.2 >/dev/null&
ip netns exec test1 iperf3 -c 2.2.2.2 -B 1.1.1.1 -u -l 1500 -b 3g -t 100 >/dev/null& bpftrace -e 'kfunc:__napi_poll{@=count();} interval:s:1{exit();}'
Report RCU quiescent states periodically will resolve the issue.
--- net/core/dev.c | 3 +++ 1 file changed, 3 insertions(+)
net/core/dev.c +3 -0
@@ -6668,6 +6668,8 @@ static int napi_threaded_poll(void *data)void *have;while (!napi_thread_wait (napi)) { +unsigned long last_qs = jiffies; +for (;;) {bool repoll = false;
@@ -6692,6 +6694,7 @@ static int napi_threaded_poll(void *data)if (!repoll)break ; +rcu_softirq_qs_periodic (last_qs);cond_resched (); } }
Signature · 1 line
2.43.0