5.10.137-rc1 review
Subsystems (9)
Greg Kroah-Hartman
maintainerPATCH 310/545 intel_th: msu-sink: Potential dereference of null pointer
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 82f76a4a720791d889de775b5f7541d601efc8bd ]
The return value of dma_alloc_coherent() needs to be checked. To avoid use of null pointer in sg_set_buf() in case of the failure of alloc.
--- drivers/hwtracing/intel_th/msu-sink.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwtracing/intel_th/msu-sink.c +3 -0
@@ -71,6 +71,9 @@ static int msu_sink_alloc_window(void *data, struct sg_table **sgt, size_t size) block =dma_alloc_coherent (priv->dev->parent->parent,PAGE_SIZE , &sg_dma_address (sg_ptr),GFP_KERNEL ); +if (!block) +return -ENOMEM ; +sg_set_buf (sg_ptr, block,PAGE_SIZE ); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 311/545 intel_th: msu: Fix vmalloced buffers
In reply to Greg Kroah-HartmanFrom: Alexander Shishkin <[email protected]>
[ Upstream commit ac12ad3ccf6d386e64a9d6a890595a2509d24edd ]
After commit f5ff79fddf0e ("dma-mapping: remove CONFIG_DMA_REMAP") there's a chance of DMA buffer getting allocated via vmalloc(), which messes up the mmapping code:
Quoted 5 lines
RIP: msc_mmap_fault [intel_th_msu] Call Trace: <TASK> __do_fault do_fault
...
Fix this by accounting for vmalloc possibility.
--- drivers/hwtracing/intel_th/msu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/hwtracing/intel_th/msu.c +12 -2
@@ -1053,6 +1053,16 @@ msc_buffer_set_uc(struct msc_window *win, unsigned int nr_segs) {}static inline void msc_buffer_set_wb (struct msc_window *win) {}#endif /* CONFIG_X86 */ +static struct page *msc_sg_page (struct scatterlist *sg) +{ +void *addr =sg_virt (sg); + +if (is_vmalloc_addr (addr)) +return vmalloc_to_page (addr); + +return sg_page (sg); +} +/** * msc_buffer_win_alloc() - alloc a window for a multiblock mode * @msc: MSC device
@@ -1125,7 +1135,7 @@ static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win)int i;for_each_sg (win->sgt->sgl, sg, win->nr_segs, i) { -struct page *page =sg_page (sg); +struct page *page =msc_sg_page (sg); page->mapping =NULL ; dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE,
@@ -1387,7 +1397,7 @@ static struct page *msc_buffer_get_page(struct msc *msc, unsigned long pgoff) pgoff -= win->pgoff;for_each_sg (win->sgt->sgl, sg, win->nr_segs, blk) { -struct page *page =sg_page (sg); +struct page *page =msc_sg_page (sg);size_t pgsz =PFN_DOWN (sg->length);if (pgoff < pgsz)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 312/545 staging: rtl8192u: Fix sleep in atomic context bug in dm_fsync_timer_callback
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit 6a0c054930d554ad8f8044ef1fc856d9da391c81 ]
There are sleep in atomic context bugs when dm_fsync_timer_callback is executing. The root cause is that the memory allocation functions with GFP_KERNEL or GFP_NOIO parameters are called in dm_fsync_timer_callback which is a timer handler. The call paths that could trigger bugs are shown below:
(interrupt context)dm_fsync_timer_callback
write_nic_byte
kzalloc(sizeof(data), GFP_KERNEL); //may sleep usb_control_msg
kmalloc(.., GFP_NOIO); //may sleep
write_nic_dword
kzalloc(sizeof(data), GFP_KERNEL); //may sleep usb_control_msg
kmalloc(.., GFP_NOIO); //may sleep
This patch uses delayed work to replace timer and moves the operations that may sleep into the delayed work in order to mitigate bugs.
--- drivers/staging/rtl8192u/r8192U.h | 2 +- drivers/staging/rtl8192u/r8192U_dm.c | 38 +++++++++++++--------------- drivers/staging/rtl8192u/r8192U_dm.h | 2 +- 3 files changed, 20 insertions(+), 22 deletions(-)
drivers/staging/rtl8192u/r8192U.h +1 -1
@@ -1013,7 +1013,7 @@ typedef struct r8192_priv {bool bis_any_nonbepkts;bool bcurrent_turbo_EDCA;bool bis_cur_rdlstate; -struct timer_list fsync_timer; +struct delayed_work fsync_work;bool bfsync_processing;/* 500ms Fsync timer is active or not */ u32 rate_record;u32 rateCountDiffRecord;
drivers/staging/rtl8192u/r8192U_dm.c +18 -20
@@ -2578,19 +2578,20 @@ static void dm_init_fsync(struct net_device *dev) priv->ieee80211->fsync_seconddiff_ratethreshold =200 ; priv->ieee80211->fsync_state = Default_Fsync; priv->framesyncMonitor =1 ;/* current default 0xc38 monitor on */ -timer_setup (&priv->fsync_timer, dm_fsync_timer_callback,0 ); +INIT_DELAYED_WORK (&priv->fsync_work, dm_fsync_work_callback); }static void dm_deInit_fsync (struct net_device *dev) {struct r8192_priv *priv =ieee80211_priv (dev); -del_timer_sync (&priv->fsync_timer); +cancel_delayed_work_sync (&priv->fsync_work); } -void dm_fsync_timer_callback (struct timer_list *t) +void dm_fsync_work_callback (struct work_struct *work) { -struct r8192_priv *priv =from_timer (priv, t, fsync_timer); +struct r8192_priv *priv = + container_of(work, struct r8192_priv, fsync_work.work);struct net_device *dev = priv->ieee80211->dev;u32 rate_index, rate_count =0 , rate_count_diff =0 ;bool bSwitchFromCountDiff = false;
@@ -2657,17 +2658,16 @@ void dm_fsync_timer_callback(struct timer_list *t) } }if (bDoubleTimeInterval) { -if (timer_pending (&priv->fsync_timer)) -del_timer_sync (&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + -msecs_to_jiffies (priv->ieee80211->fsync_time_interval*priv->ieee80211->fsync_multiple_timeinterval); -add_timer (&priv->fsync_timer); +cancel_delayed_work_sync (&priv->fsync_work); +schedule_delayed_work (&priv->fsync_work, +msecs_to_jiffies (priv + ->ieee80211->fsync_time_interval * + priv->ieee80211->fsync_multiple_timeinterval)); }else { -if (timer_pending (&priv->fsync_timer)) -del_timer_sync (&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + -msecs_to_jiffies (priv->ieee80211->fsync_time_interval); -add_timer (&priv->fsync_timer); +cancel_delayed_work_sync (&priv->fsync_work); +schedule_delayed_work (&priv->fsync_work, +msecs_to_jiffies (priv + ->ieee80211->fsync_time_interval)); } }else {/* Let Register return to default value; */
@@ -2695,7 +2695,7 @@ static void dm_EndSWFsync(struct net_device *dev)struct r8192_priv *priv =ieee80211_priv (dev);RT_TRACE (COMP_HALDM ,"%s\n" , __func__); -del_timer_sync (&(priv->fsync_timer)); +cancel_delayed_work_sync (&priv->fsync_work);/* Let Register return to default value; */ if (priv->bswitch_fsync) {
@@ -2736,11 +2736,9 @@ static void dm_StartSWFsync(struct net_device *dev)if (priv->ieee80211->fsync_rate_bitmap & rateBitmap) priv->rate_record += priv->stats.received_rate_histogram[1 ][rateIndex]; } -if (timer_pending (&priv->fsync_timer)) -del_timer_sync (&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + -msecs_to_jiffies (priv->ieee80211->fsync_time_interval); -add_timer (&priv->fsync_timer); +cancel_delayed_work_sync (&priv->fsync_work); +schedule_delayed_work (&priv->fsync_work, +msecs_to_jiffies (priv->ieee80211->fsync_time_interval));write_nic_dword (dev, rOFDM0_RxDetector2,0x465c12cd ); }
drivers/staging/rtl8192u/r8192U_dm.h +1 -1
@@ -166,7 +166,7 @@ void dm_force_tx_fw_info(struct net_device *dev,void dm_init_edca_turbo (struct net_device *dev);void dm_rf_operation_test_callback (unsigned long data);void dm_rf_pathcheck_workitemcallback (struct work_struct *work); -void dm_fsync_timer_callback (struct timer_list *t); +void dm_fsync_work_callback (struct work_struct *work);void dm_cck_txpower_adjust (struct net_device *dev,bool binch14);void dm_shadow_init (struct net_device *dev);void dm_initialize_txpower_tracking (struct net_device *dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 313/545 mmc: sdhci-of-esdhc: Fix refcount leak in esdhc_signal_voltage_switch
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit b5899a3e2f783a27b268e38d37f9b24c71bddf45 ]
of_find_matching_node() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak. of_node_put() checks null pointer.
--- drivers/mmc/host/sdhci-of-esdhc.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci-of-esdhc.c +1 -0
@@ -904,6 +904,7 @@ static int esdhc_signal_voltage_switch(struct mmc_host *mmc, scfg_node =of_find_matching_node (NULL , scfg_device_ids);if (scfg_node) scfg_base =of_iomap (scfg_node,0 ); +of_node_put (scfg_node);if (scfg_base) { sdhciovselcr =SDHCIOVSELCR_TGLEN |SDHCIOVSELCR_VSELVAL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 314/545 memstick/ms_block: Fix some incorrect memory allocation
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 2e531bc3e0d86362fcd8a577b3278d9ef3cc2ba0 ]
Some functions of the bitmap API take advantage of the fact that a bitmap is an array of long.
So, to make sure this assertion is correct, allocate bitmaps with bitmap_zalloc() instead of kzalloc()+hand-computed number of bytes.
While at it, also use bitmap_free() instead of kfree() to keep the semantic.
--- drivers/memstick/core/ms_block.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/memstick/core/ms_block.c +5 -5
@@ -1335,17 +1335,17 @@ static int msb_ftl_initialize(struct msb_data *msb) msb->zone_count = msb->block_count /MS_BLOCKS_IN_ZONE ; msb->logical_block_count = msb->zone_count *496 -2 ; - msb->used_blocks_bitmap =kzalloc (msb->block_count /8 ,GFP_KERNEL ); - msb->erased_blocks_bitmap =kzalloc (msb->block_count /8 ,GFP_KERNEL ); + msb->used_blocks_bitmap =bitmap_zalloc (msb->block_count,GFP_KERNEL ); + msb->erased_blocks_bitmap =bitmap_zalloc (msb->block_count,GFP_KERNEL ); msb->lba_to_pba_table =kmalloc_array (msb->logical_block_count,sizeof (u16),GFP_KERNEL );if (!msb->used_blocks_bitmap || !msb->lba_to_pba_table || !msb->erased_blocks_bitmap) { -kfree (msb->used_blocks_bitmap); +bitmap_free (msb->used_blocks_bitmap); +bitmap_free (msb->erased_blocks_bitmap);kfree (msb->lba_to_pba_table); -kfree (msb->erased_blocks_bitmap);return -ENOMEM ; }
@@ -1953,7 +1953,7 @@ static int msb_bd_open(struct block_device *bdev, fmode_t mode)static void msb_data_clear (struct msb_data *msb) {kfree (msb->boot_page); -kfree (msb->used_blocks_bitmap); +bitmap_free (msb->used_blocks_bitmap);kfree (msb->lba_to_pba_table);kfree (msb->cache); msb->card =NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 315/545 memstick/ms_block: Fix a memory leak
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 54eb7a55be6779c4d0c25eaf5056498a28595049 ]
'erased_blocks_bitmap' is never freed. As it is allocated at the same time as 'used_blocks_bitmap', it is likely that it should be freed also at the same time.
Add the corresponding bitmap_free() in msb_data_clear().
--- drivers/memstick/core/ms_block.c | 1 + 1 file changed, 1 insertion(+)
drivers/memstick/core/ms_block.c +1 -0
@@ -1954,6 +1954,7 @@ static void msb_data_clear(struct msb_data *msb) {kfree (msb->boot_page);bitmap_free (msb->used_blocks_bitmap); +bitmap_free (msb->erased_blocks_bitmap);kfree (msb->lba_to_pba_table);kfree (msb->cache); msb->card =NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 316/545 mmc: sdhci-of-at91: fix set_uhs_signaling rewriting of MC1R
In reply to Greg Kroah-HartmanFrom: Eugen Hristev <[email protected]>
[ Upstream commit 5987e6ded29d52e42fc7b06aa575c60a25eee38e ]
In set_uhs_signaling, the DDR bit is being set by fully writing the MC1R register.
This can lead to accidental erase of certain bits in this register. Avoid this by doing a read-modify-write operation.
--- drivers/mmc/host/sdhci-of-at91.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-of-at91.c +7 -2
@@ -100,8 +100,13 @@ static void sdhci_at91_set_clock(struct sdhci_host *host, unsigned int clock)static void sdhci_at91_set_uhs_signaling (struct sdhci_host *host,unsigned int timing) { -if (timing ==MMC_TIMING_MMC_DDR52 ) -sdhci_writeb (host,SDMMC_MC1R_DDR ,SDMMC_MC1R ); +u8 mc1r; + +if (timing ==MMC_TIMING_MMC_DDR52 ) { + mc1r =sdhci_readb (host,SDMMC_MC1R ); + mc1r |=SDMMC_MC1R_DDR ; +sdhci_writeb (host, mc1r,SDMMC_MC1R ); + }sdhci_set_uhs_signaling (host, timing); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 317/545 mmc: block: Add single read for 4k sector cards
In reply to Greg Kroah-HartmanFrom: Christian Loehle <[email protected]>
[ Upstream commit b3fa3e6dccc465969721b8bd2824213bd235efeb ]
Cards with 4k native sector size may only be read 4k-aligned, accommodate for this in the single read recovery and use it.
--- drivers/mmc/core/block.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/mmc/core/block.c +14 -14
@@ -169,7 +169,7 @@ static inline int mmc_blk_part_switch(struct mmc_card *card, unsigned int part_type);static void mmc_blk_rw_rq_prep (struct mmc_queue_req *mqrq,struct mmc_card *card, -int disable_multi, +int recovery_mode,struct mmc_queue *mq);static void mmc_blk_hsq_req_done (struct mmc_request *mrq);
@@ -1247,7 +1247,7 @@ static void mmc_blk_eval_resp_error(struct mmc_blk_request *brq) }static void mmc_blk_data_prep (struct mmc_queue *mq,struct mmc_queue_req *mqrq, -int disable_multi,bool *do_rel_wr_p, +int recovery_mode,bool *do_rel_wr_p,bool *do_data_tag_p) {struct mmc_blk_data *md = mq->blkdata;
@@ -1311,12 +1311,12 @@ static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq, brq->data.blocks--;/* -* After a read error, we redo the request one sector +* After a read error, we redo the request one (native) sector * at a time in order to accurately determine which * sectors can be read successfully. */ -if (disable_multi) - brq->data.blocks =1 ; +if (recovery_mode) + brq->data.blocks =queue_physical_block_size (mq->queue) >>9 ;/* * Some controllers have HW issues while operating
@@ -1533,7 +1533,7 @@ static int mmc_blk_cqe_issue_rw_rq(struct mmc_queue *mq, struct request *req)static void mmc_blk_rw_rq_prep (struct mmc_queue_req *mqrq,struct mmc_card *card, -int disable_multi, +int recovery_mode,struct mmc_queue *mq) {u32 readcmd, writecmd;
@@ -1542,7 +1542,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,struct mmc_blk_data *md = mq->blkdata;bool do_rel_wr, do_data_tag; -mmc_blk_data_prep (mq, mqrq, disable_multi, &do_rel_wr, &do_data_tag); +mmc_blk_data_prep (mq, mqrq, recovery_mode, &do_rel_wr, &do_data_tag); brq->mrq.cmd = &brq->cmd;
@@ -1633,7 +1633,7 @@ static int mmc_blk_fix_state(struct mmc_card *card, struct request *req)#define MMC_READ_SINGLE_RETRIES 2 -/* Single sector read during recovery */ +/* Single (native) sector read during recovery */ static void mmc_blk_read_single (struct mmc_queue *mq,struct request *req) {struct mmc_queue_req *mqrq =req_to_mmc_queue_req (req);
@@ -1641,6 +1641,7 @@ static void mmc_blk_read_single(struct mmc_queue *mq, struct request *req)struct mmc_card *card = mq->card;struct mmc_host *host = card->host;blk_status_t error =BLK_STS_OK ; +size_t bytes_per_read =queue_physical_block_size (mq->queue); do { u32 status;
@@ -1675,13 +1676,13 @@ static void mmc_blk_read_single(struct mmc_queue *mq, struct request *req)else error =BLK_STS_OK ; - }while (blk_update_request (req, error,512 )); + }while (blk_update_request (req, error, bytes_per_read));return ; error_exit: mrq->data->bytes_xfered =0 ; -blk_update_request (req,BLK_STS_IOERR ,512 ); +blk_update_request (req,BLK_STS_IOERR , bytes_per_read);/* Let it try the remaining request again */ if (mqrq->retries >MMC_MAX_RETRIES -1 ) mqrq->retries =MMC_MAX_RETRIES -1 ;
@@ -1822,10 +1823,9 @@ static void mmc_blk_mq_rw_recovery(struct mmc_queue *mq, struct request *req)return ; } -/* FIXME: Missing single sector read for large sector size */ -if (!mmc_large_sector (card) &&rq_data_dir (req) ==READ && - brq->data.blocks >1 ) { -/* Read one sector at a time */ +if (rq_data_dir (req) ==READ && brq->data.blocks > +queue_physical_block_size (mq->queue) >>9 ) { +/* Read one (native) sector at a time */ mmc_blk_read_single (mq, req);return ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 318/545 KVM: s390: pv: leak the topmost page table when destroy fails
In reply to Greg Kroah-HartmanFrom: Claudio Imbrenda <[email protected]>
[ Upstream commit faa2f72cb3569256480c5540d242c84e99965160 ]
Each secure guest must have a unique ASCE (address space control element); we must avoid that new guests use the same page for their ASCE, to avoid errors.
Since the ASCE mostly consists of the address of the topmost page table (plus some flags), we must not return that memory to the pool unless the ASCE is no longer in use.
Only a successful Destroy Secure Configuration UVC will make the ASCE reusable again.
If the Destroy Configuration UVC fails, the ASCE cannot be reused for a secure guest (either for the ASCE or for other memory areas). To avoid a collision, it must not be used again. This is a permanent error and the page becomes in practice unusable, so we set it aside and leak it. On failure we already leak other memory that belongs to the ultravisor (i.e. the variable and base storage for a guest) and not leaking the topmost page table was an oversight.
This error (and thus the leakage) should not happen unless the hardware is broken or KVM has some unknown serious bug.
Message-Id: <[email protected]>
--- arch/s390/include/asm/gmap.h | 2 + arch/s390/kvm/pv.c | 9 ++-- arch/s390/mm/gmap.c | 86 ++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 3 deletions(-)
arch/s390/include/asm/gmap.h +2 -0
@@ -148,4 +148,6 @@ void gmap_sync_dirty_log_pmd(struct gmap *gmap, unsigned long dirty_bitmap[4], unsigned long gaddr, unsigned long vmaddr);int gmap_mark_unmergeable (void );void s390_reset_acc (struct mm_struct *mm); +void s390_unlist_old_asce (struct gmap *gmap); +int s390_replace_asce (struct gmap *gmap);#endif /* _ASM_S390_GMAP_H */
arch/s390/kvm/pv.c +6 -3
@@ -163,10 +163,13 @@ int kvm_s390_pv_deinit_vm(struct kvm *kvm, u16 *rc, u16 *rrc)atomic_set (&kvm->mm->context.is_protected,0 );KVM_UV_EVENT (kvm,3 ,"PROTVIRT DESTROY VM: rc %x rrc %x" , *rc, *rrc);WARN_ONCE (cc,"protvirt destroy vm failed rc %x rrc %x" , *rc, *rrc); -/* Inteded memory leak on "impossible" error */ -if (!cc) +/* Intended memory leak on "impossible" error */ +if (!cc) {kvm_s390_pv_dealloc_vm (kvm); -return cc ? -EIO :0 ; +return 0 ; + } +s390_replace_asce (kvm->arch.gmap); +return -EIO ; }int kvm_s390_pv_init_vm (struct kvm *kvm,u16 *rc,u16 *rrc)
arch/s390/mm/gmap.c +86 -0
89 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 319/545 PCI/portdrv: Dont disable AER reporting in get_port_device_capability()
In reply to Greg Kroah-HartmanFrom: Stefan Roese <[email protected]>
[ Upstream commit 8795e182b02dc87e343c79e73af6b8b7f9c5e635 ]
AER reporting is currently disabled in the DevCtl registers of all non Root Port PCIe devices on systems using pcie_ports_native || host->native_aer, disabling AER completely in such systems. This is because 2bd50dd800b5 ("PCI: PCIe: Disable PCIe port services during port initialization"), added a call to pci_disable_pcie_error_reporting() *after* the AER setup was completed for the PCIe device tree.
Here a longer analysis about the current status of AER enabling / disabling upon bootup provided by Bjorn:
pcie_portdrv_probe
pcie_port_device_register
get_port_device_capability
pci_disable_pcie_error_reporting
clear CERE NFERE FERE URRE # <-- disable for RP USP DSP
pcie_device_init
device_register # new AER service device
aer_probe
aer_enable_rootport # RP only
set_downstream_devices_error_reporting
set_device_error_reporting # self (RP)
if (RP || USP || DSP)
pci_enable_pcie_error_reporting
set CERE NFERE FERE URRE # <-- enable for RP
pci_walk_bus
set_device_error_reporting
if (RP || USP || DSP)
pci_enable_pcie_error_reporting
set CERE NFERE FERE URRE # <-- enable for USP DSP
In a typical Root Port -> Endpoint hierarchy, the above:
- Disables Error Reporting for the Root Port,
- Enables Error Reporting for the Root Port,
- Does NOT enable Error Reporting for the Endpoint because it is not a Root Port or Switch Port.
In a deeper Root Port -> Upstream Switch Port -> Downstream Switch Port -> Endpoint hierarchy:
- Disables Error Reporting for the Root Port,
- Enables Error Reporting for the Root Port,
- Enables Error Reporting for both Switch Ports,
- Does NOT enable Error Reporting for the Endpoint because it is not a Root Port or Switch Port,
- Disables Error Reporting for the Switch Ports when pcie_portdrv_probe() claims them. AER does not re-enable it because these are not Root Ports.
Remove this call to pci_disable_pcie_error_reporting() from get_port_device_capability(), leaving the already enabled AER configuration intact. With this change, AER is enabled in the Root Port and the PCIe switch upstream and downstream ports. Only the PCIe Endpoints don't have AER enabled yet. A follow-up patch will take care of this Endpoint enabling.
--- drivers/pci/pcie/portdrv_core.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/pci/pcie/portdrv_core.c +1 -8
@@ -222,15 +222,8 @@ static int get_port_device_capability(struct pci_dev *dev)#ifdef CONFIG_PCIEAER if (dev->aer_cap &&pci_aer_available () && - (pcie_ports_native || host->native_aer)) { + (pcie_ports_native || host->native_aer)) services |=PCIE_PORT_SERVICE_AER ; - -/* -* Disable AER on this port in case it's been enabled by the -* BIOS (the AER service driver will enable it when necessary). -*/ -pci_disable_pcie_error_reporting (dev); - }#endif /*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 320/545 PCI: qcom: Set up rev 2.1.0 PARF_PHY before enabling clocks
In reply to Greg Kroah-HartmanFrom: Christian Marangi <[email protected]>
[ Upstream commit 38f897ae3d44900f627cad708a15db498ce2ca31 ]
We currently enable clocks BEFORE we write to PARF_PHY_CTRL reg to enable clocks and resets. This causes the driver to never set to a ready state with the error 'Phy link never came up'.
This is caused by the PHY clock getting enabled before setting the required bits in the PARF regs.
A workaround for this was set but with this new discovery we can drop the workaround and use a proper solution to the problem by just enabling the clock only AFTER the PARF_PHY_CTRL bit is set.
This correctly sets up the PCIe link and makes it usable even when a bootloader leaves the PCIe link in an undefined state.
--- drivers/pci/controller/dwc/pcie-qcom.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/pci/controller/dwc/pcie-qcom.c +4 -6
@@ -320,8 +320,6 @@ static int qcom_pcie_init_2_1_0(struct qcom_pcie *pcie)reset_control_assert (res->ext_reset);reset_control_assert (res->phy_reset); -writel (1 , pcie->parf +PCIE20_PARF_PHY_CTRL ); - ret =regulator_bulk_enable (ARRAY_SIZE (res->supplies), res->supplies);if (ret <0 ) {dev_err (dev,"cannot enable regulators\n" );
@@ -364,15 +362,15 @@ static int qcom_pcie_init_2_1_0(struct qcom_pcie *pcie) goto err_deassert_axi; } - ret =clk_bulk_prepare_enable (ARRAY_SIZE (res->clks), res->clks); -if (ret) - goto err_clks; -/* enable PCIe clocks and resets */ val =readl (pcie->parf +PCIE20_PARF_PHY_CTRL ); val &= ~BIT (0 );writel (val, pcie->parf +PCIE20_PARF_PHY_CTRL ); + ret =clk_bulk_prepare_enable (ARRAY_SIZE (res->clks), res->clks); +if (ret) + goto err_clks; +if (of_device_is_compatible (node,"qcom,pcie-ipq8064" ) ||of_device_is_compatible (node,"qcom,pcie-ipq8064-v2" )) { writel(PCS_DEEMPH_TX_DEEMPH_GEN1(24) |
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 321/545 scsi: smartpqi: Fix DMA direction for RAID requests
In reply to Greg Kroah-HartmanFrom: Mahesh Rajashekhara <[email protected]>
[ Upstream commit 69695aeaa6621bc49cdd7a8e5a8d1042461e496e ]
Correct a SOP READ and WRITE DMA flags for some requests.
This update corrects DMA direction issues with SCSI commands removed from the controller's internal lookup table.
Currently, SCSI READ BLOCK LIMITS (0x5) was removed from the controller lookup table and exposed a DMA direction flag issue.
SCSI READ BLOCK LIMITS was recently removed from our controller lookup table so the controller uses the respective IU flag field to set the DMA data direction. Since the DMA direction is incorrect the FW never completes the request causing a hang.
Some SCSI commands which use SCSI READ BLOCK LIMITS
* sg_map
* mt -f /dev/stX status
After updating controller firmware, users may notice their tape units failing. This patch resolves the issue.
Also, the AIO path DMA direction is correct.
The DMA direction flag is a day-one bug with no reported BZ.
--- drivers/scsi/smartpqi/smartpqi_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +2 -2
@@ -4997,10 +4997,10 @@ static int pqi_raid_submit_scsi_cmd_with_io_request( }switch (scmd->sc_data_direction) { -case DMA_TO_DEVICE : +case DMA_FROM_DEVICE : request->data_direction =SOP_READ_FLAG ;break ; -case DMA_FROM_DEVICE : +case DMA_TO_DEVICE : request->data_direction =SOP_WRITE_FLAG ;break ;case DMA_NONE :
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 322/545 xtensa: iss/network: provide release() callback
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
[ Upstream commit 8864fb8359682912ee99235db7db916733a1fd7b ]
Provide release() callback for the platform device embedded into struct iss_net_private and registered in the iss_net_configure so that platform_device_unregister could be called for it.
--- arch/xtensa/platforms/iss/network.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/xtensa/platforms/iss/network.c +10 -0
@@ -502,6 +502,15 @@ static const struct net_device_ops iss_netdev_ops = { .ndo_set_rx_mode = iss_net_set_multicast_list, }; +static void iss_net_pdev_release (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct iss_net_private *lp = + container_of(pdev, struct iss_net_private, pdev); + +free_netdev (lp->dev); +} +static int iss_net_configure (int index,char *init) {struct net_device *dev;
@@ -558,6 +567,7 @@ static int iss_net_configure(int index, char *init) lp->pdev.id = index; lp->pdev.name =DRIVER_NAME ; + lp->pdev.dev.release = iss_net_pdev_release;platform_device_register (&lp->pdev);SET_NETDEV_DEV (dev, &lp->pdev.dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 323/545 xtensa: iss: fix handling error cases in iss_net_configure()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 628ccfc8f5f79dd548319408fcc53949fe97b258 ]
The 'pdev' and 'netdev' need to be released in error cases of iss_net_configure().
Change the return type of iss_net_configure() to void, because it's not used.
--- arch/xtensa/platforms/iss/network.c | 32 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 17 deletions(-)
arch/xtensa/platforms/iss/network.c +15 -17
@@ -511,16 +511,15 @@ static void iss_net_pdev_release(struct device *dev)free_netdev (lp->dev); } -static int iss_net_configure (int index,char *init) +static void iss_net_configure (int index,char *init) {struct net_device *dev;struct iss_net_private *lp; -int err; dev =alloc_etherdev (sizeof (*lp));if (dev ==NULL ) {pr_err ("eth_configure: failed to allocate device\n" ); -return 1 ; +return ; }/* Initialize private element. */
@@ -549,7 +548,7 @@ static int iss_net_configure(int index, char *init)if (!tuntap_probe (lp, index, init)) {pr_err ("%s: invalid arguments. Skipping device!\n" , dev->name); - goto errout; + goto err_free_netdev; }pr_info ("Netdevice %d (%pM)\n" , index, dev->dev_addr);
@@ -557,7 +556,8 @@ static int iss_net_configure(int index, char *init)/* sysfs register */ if (!driver_registered) { -platform_driver_register (&iss_net_driver); +if (platform_driver_register (&iss_net_driver)) + goto err_free_netdev; driver_registered =1 ; }
@@ -568,7 +568,8 @@ static int iss_net_configure(int index, char *init) lp->pdev.id = index; lp->pdev.name =DRIVER_NAME ; lp->pdev.dev.release = iss_net_pdev_release; -platform_device_register (&lp->pdev); +if (platform_device_register (&lp->pdev)) + goto err_free_netdev;SET_NETDEV_DEV (dev, &lp->pdev.dev); dev->netdev_ops = &iss_netdev_ops;
@@ -577,23 +578,20 @@ static int iss_net_configure(int index, char *init) dev->irq =-1 ;rtnl_lock (); - err =register_netdevice (dev); -rtnl_unlock (); - -if (err) { +if (register_netdevice (dev)) { +rtnl_unlock ();pr_err ("%s: error registering net device!\n" , dev->name); -/* XXX: should we call ->remove() here? */ -free_netdev (dev); -return 1 ; +platform_device_unregister (&lp->pdev); +return ; } +rtnl_unlock ();timer_setup (&lp->tl, iss_net_user_timer_expire,0 ); -return 0 ; +return ; -errout: -/* FIXME: unregister; free, etc.. */ -return -EIO ; +err_free_netdev: +free_netdev (dev); }/* ------------------------------------------------------------------------- */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 324/545 usb: gadget: udc: amd5536 depends on HAS_DMA
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 8097cf2fb3b2205257f1c76f4808e3398d66b6d9 ]
USB_AMD5536UDC should depend on HAS_DMA since it selects USB_SNP_CORE, which depends on HAS_DMA and since 'select' does not follow any dependency chains.
Fixes this kconfig warning:
WARNING: unmet direct dependencies detected for USB_SNP_CORE
Depends on [n]: USB_SUPPORT [=y] && USB_GADGET [=y] && (USB_AMD5536UDC [=y] || USB_SNP_UDC_PLAT [=n]) && HAS_DMA [=n] Selected by [y]:
- USB_AMD5536UDC [=y] && USB_SUPPORT [=y] && USB_GADGET [=y] && USB_PCI [=y]
--- drivers/usb/gadget/udc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/Kconfig +1 -1
@@ -311,7 +311,7 @@ source "drivers/usb/gadget/udc/bdc/Kconfig" config USB_AMD5536UDC tristate "AMD5536 UDC" - depends on USB_PCI + depends on USB_PCI && HAS_DMA select USB_SNP_CORE help The AMD5536 UDC is part of the AMD Geode CS5536, an x86 southbridge.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 325/545 usb: aspeed-vhub: Fix refcount leak bug in ast_vhub_init_desc()
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 220fafb4ed04187e9c17be4152da5a7f2ffbdd8c ]
We should call of_node_put() for the reference returned by of_get_child_by_name() which has increased the refcount.
--- drivers/usb/gadget/udc/aspeed-vhub/hub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/udc/aspeed-vhub/hub.c +3 -1
@@ -1033,8 +1033,10 @@ static int ast_vhub_init_desc(struct ast_vhub *vhub)/* Initialize vhub String Descriptors. */ INIT_LIST_HEAD (&vhub->vhub_str_desc); desc_np =of_get_child_by_name (vhub_np,"vhub-strings" ); -if (desc_np) +if (desc_np) { ret =ast_vhub_of_parse_str_desc (vhub, desc_np); +of_node_put (desc_np); + }else ret =ast_vhub_str_alloc_add (vhub, &ast_vhub_strings);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 326/545 usb: dwc3: core: Deprecate GCTL.CORESOFTRESET
In reply to Greg Kroah-HartmanFrom: Thinh Nguyen <[email protected]>
[ Upstream commit afbd04e66e5d16ca3c7ea2e3c56eca25558eacf3 ]
Synopsys IP DWC_usb32 and DWC_usb31 version 1.90a and above deprecated GCTL.CORESOFTRESET. The DRD mode switching flow is updated to remove the GCTL soft reset. Add version checks to prevent using deprecated setting in mode switching flow.
--- drivers/usb/dwc3/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +2 -1
@@ -159,7 +159,8 @@ static void __dwc3_set_mode(struct work_struct *work) }/* For DRD host or device mode only */ -if (dwc->desired_dr_role !=DWC3_GCTL_PRTCAP_OTG ) { + if ((DWC3_IP_IS(DWC3) || DWC3_VER_IS_PRIOR(DWC31, 190A)) && + dwc->desired_dr_role !=DWC3_GCTL_PRTCAP_OTG ) { reg =dwc3_readl (dwc->regs,DWC3_GCTL ); reg |=DWC3_GCTL_CORESOFTRESET ;dwc3_writel (dwc->regs,DWC3_GCTL , reg);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 327/545 usb: dwc3: core: Do not perform GCTL_CORE_SOFTRESET during bootup
In reply to Greg Kroah-HartmanFrom: Rohith Kollalsi <[email protected]>
[ Upstream commit 07903626d98853e605fe63e5ce149f1b7314bbea ]
According to the programming guide, it is recommended to perform a GCTL_CORE_SOFTRESET only when switching the mode from device to host or host to device. However, it is found that during bootup when __dwc3_set_mode() is called for the first time, GCTL_CORESOFTRESET is done with suspendable bit(BIT 17) of DWC3_GUSB3PIPECTL set. This some times leads to issues like controller going into bad state and controller registers reading value zero. Until GCTL_CORESOFTRESET is done and run/stop bit is set core initialization is not complete. Setting suspendable bit of DWC3_GUSB3PIPECTL and then performing GCTL_CORESOFTRESET is therefore not recommended. Avoid this by only performing the reset if current_dr_role is set, that is, when doing subsequent role switching.
--- drivers/usb/dwc3/core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/usb/dwc3/core.c +7 -3
@@ -158,9 +158,13 @@ static void __dwc3_set_mode(struct work_struct *work)break ; } -/* For DRD host or device mode only */ - if ((DWC3_IP_IS(DWC3) || DWC3_VER_IS_PRIOR(DWC31, 190A)) && - dwc->desired_dr_role !=DWC3_GCTL_PRTCAP_OTG ) { +/* +* When current_dr_role is not set, there's no role switching. +* Only perform GCTL.CoreSoftReset when there's DRD role switching. +*/ +if (dwc->current_dr_role && ((DWC3_IP_IS (DWC3 ) || + DWC3_VER_IS_PRIOR(DWC31, 190A)) && + dwc->desired_dr_role !=DWC3_GCTL_PRTCAP_OTG )) { reg =dwc3_readl (dwc->regs,DWC3_GCTL ); reg |=DWC3_GCTL_CORESOFTRESET ;dwc3_writel (dwc->regs,DWC3_GCTL , reg);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 328/545 usb: dwc3: qcom: fix missing optional irq warnings
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 69bb3520db7cecbccc9e497fc568fa5465c9d43f ]
Not all platforms have all of the four currently supported wakeup interrupts so use the optional irq helpers when looking up interrupts to avoid printing error messages when an optional interrupt is not found:
dwc3-qcom a6f8800.usb: error -ENXIO: IRQ hs_phy_irq not found
--- drivers/usb/dwc3/dwc3-qcom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +2 -2
@@ -443,9 +443,9 @@ static int dwc3_qcom_get_irq(struct platform_device *pdev,int ret;if (np) - ret =platform_get_irq_byname (pdev_irq, name); + ret =platform_get_irq_byname_optional (pdev_irq, name);else - ret =platform_get_irq (pdev_irq, num); + ret =platform_get_irq_optional (pdev_irq, num);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 329/545 eeprom: idt_89hpesx: uninitialized data in idt_dbgfs_csr_write()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 71d46f1ff2212ced4852c7e77c5176382a1bdcec ]
The simple_write_to_buffer() function will return positive/success if it is able to write a single byte anywhere within the buffer. However that potentially leaves a lot of the buffer uninitialized.
In this code it's better to return 0 if the offset is non-zero. This code is not written to support partial writes. And then return -EFAULT if the buffer is not completely initialized.
--- drivers/misc/eeprom/idt_89hpesx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/misc/eeprom/idt_89hpesx.c +6 -2
@@ -940,14 +940,18 @@ static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf,u32 csraddr, csrval;char *buf; +if (*offp) +return 0 ; +/* Copy data from User-space */ buf =kmalloc (count +1 ,GFP_KERNEL );if (!buf)return -ENOMEM ; - ret =simple_write_to_buffer (buf, count, offp, ubuf, count); -if (ret <0 ) +if (copy_from_user (buf, ubuf, count)) { + ret = -EFAULT ; goto free_buf; + } buf[count] =0 ;/* Find position of colon in the buffer */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 330/545 interconnect: imx: fix max_node_id
In reply to Greg Kroah-HartmanFrom: Peng Fan <[email protected]>
[ Upstream commit bd734481e172b4827af09c9ab06c51d2ab7201e6 ]
max_node_id not equal to the ARRAY_SIZE of node array, need increase 1, otherwise xlate will fail for the last entry. And rename max_node_id to num_nodes to reflect the reality.
--- drivers/interconnect/imx/imx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/interconnect/imx/imx.c +4 -4
@@ -226,16 +226,16 @@ int imx_icc_register(struct platform_device *pdev,struct device *dev = &pdev->dev;struct icc_onecell_data *data;struct icc_provider *provider; -int max_node_id; +int num_nodes;int ret;/* icc_onecell_data is indexed by node_id, unlike nodes param */ - max_node_id =get_max_node_id (nodes, nodes_count); - data =devm_kzalloc (dev,struct_size (data, nodes, max_node_id), + num_nodes =get_max_node_id (nodes, nodes_count) +1 ; + data =devm_kzalloc (dev,struct_size (data, nodes, num_nodes),GFP_KERNEL );if (!data)return -ENOMEM ; - data->num_nodes = max_node_id; + data->num_nodes = num_nodes; provider =devm_kzalloc (dev,sizeof (*provider),GFP_KERNEL );if (!provider)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 331/545 um: random: Dont initialise hwrng struct with zero
In reply to Greg Kroah-HartmanFrom: Christopher Obbard <[email protected]>
[ Upstream commit 9e70cbd11b03889c92462cf52edb2bd023c798fa ]
Initialising the hwrng struct with zeros causes a
compile-time sparse warning:
$ ARCH=um make -j10 W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ... CHECK arch/um/drivers/random.c arch/um/drivers/random.c:31:31: sparse: warning: Using plain integer as NULL pointer
Fix the warning by not initialising the hwrng struct with zeros as it is initialised anyway during module init.
--- arch/um/drivers/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/drivers/random.c +1 -1
@@ -28,7 +28,7 @@* protects against a module being loaded twice at the same time. */ static int random_fd =-1 ; -static struct hwrng hwrng = {0 , }; +static struct hwrng hwrng;static DECLARE_COMPLETION (have_data);static int rng_dev_read (struct hwrng *rng,void *buf,size_t max,bool block)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 332/545 RDMA/rtrs: Define MIN_CHUNK_SIZE
In reply to Greg Kroah-HartmanFrom: Gioh Kim <[email protected]>
[ Upstream commit 3f3d0eabc14b6ea1fcbe85a60ee9d44e2b930b8a ]
Define MIN_CHUNK_SIZE to replace the hard-coding number. We need 4k for metadata, so MIN_CHUNK_SIZE should be at least 8k.
--- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 1 + drivers/infiniband/ulp/rtrs/rtrs-srv.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-pri.h +1 -0
@@ -56,6 +56,7 @@ enum {* somewhere between 1 and 65536 and it depends on the system. */ MAX_SESS_QUEUE_DEPTH =65536 , +MIN_CHUNK_SIZE =8192 ,RTRS_HB_INTERVAL_MS =5000 , RTRS_HB_MISSED_MAX = 5,
drivers/infiniband/ulp/rtrs/rtrs-srv.c +2 -2
@@ -2193,9 +2193,9 @@ static int check_module_params(void) sess_queue_depth, 1, MAX_SESS_QUEUE_DEPTH);return -EINVAL ; } -if (max_chunk_size <4096 || !is_power_of_2 (max_chunk_size)) { +if (max_chunk_size <MIN_CHUNK_SIZE || !is_power_of_2 (max_chunk_size)) {pr_err ("Invalid max_chunk_size value %d, has to be >= %d and should be power of two.\n" , - max_chunk_size,4096 ); + max_chunk_size,MIN_CHUNK_SIZE );return -EINVAL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 333/545 RDMA/rtrs: Avoid Wtautological-constant-out-of-range-compare
In reply to Greg Kroah-HartmanFrom: Jack Wang <[email protected]>
[ Upstream commit 0e8558476faf02ec51256cad9c487c93c346198c ]
drivers/infiniband/ulp/rtrs/rtrs-clt.c:1786:19: warning: result of comparison of constant 'MAX_SESS_QUEUE_DEPTH' (65536) with expression of type 'u16' (aka 'unsigned short') is always false [-Wtautological-constant-out-of-range-compare]
To fix it, limit MAX_SESS_QUEUE_DEPTH to u16 max, which is 65535, and drop the check in rtrs-clt, as it's the type u16 max.
--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 5 ----- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +0 -5
@@ -1728,11 +1728,6 @@ static int rtrs_rdma_conn_established(struct rtrs_clt_con *con,if (con->c.cid ==0 ) { queue_depth =le16_to_cpu (msg->queue_depth); -if (queue_depth >MAX_SESS_QUEUE_DEPTH ) { -rtrs_err (clt,"Invalid RTRS message: queue=%d\n" , - queue_depth); -return -ECONNRESET ; - }if (sess->queue_depth >0 && queue_depth != sess->queue_depth) {rtrs_err (clt,"Error: queue depth changed\n" );
drivers/infiniband/ulp/rtrs/rtrs-pri.h +2 -2
@@ -53,9 +53,9 @@ enum {* But mempool_create, create_qp and ib_post_send fail with * "cannot allocate memory" error if sess_queue_depth is too big. * Therefore the pratical max value of sess_queue_depth is -* somewhere between 1 and 65536 and it depends on the system. +* somewhere between 1 and 65534 and it depends on the system. */ -MAX_SESS_QUEUE_DEPTH =65536 , +MAX_SESS_QUEUE_DEPTH =65535 ,MIN_CHUNK_SIZE =8192 , RTRS_HB_INTERVAL_MS = 5000,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 334/545 RDMA/rtrs-srv: Fix modinfo output for stringify
In reply to Greg Kroah-HartmanFrom: Jack Wang <[email protected]>
[ Upstream commit ed6e53820ee4f68ed927de17e5675ff2a07a47e2 ]
stringify works with define, not enum.
--- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-pri.h +11 -10
@@ -23,6 +23,17 @@#define RTRS_PROTO_VER_STRING __stringify(RTRS_PROTO_VER_MAJOR) "." \ __stringify(RTRS_PROTO_VER_MINOR) +/* +* Max IB immediate data size is 2^28 (MAX_IMM_PAYL_BITS) +* and the minimum chunk size is 4096 (2^12). +* So the maximum sess_queue_depth is 65536 (2^16) in theory. +* But mempool_create, create_qp and ib_post_send fail with +* "cannot allocate memory" error if sess_queue_depth is too big. +* Therefore the pratical max value of sess_queue_depth is +* somewhere between 1 and 65534 and it depends on the system. +*/ +#define MAX_SESS_QUEUE_DEPTH 65535 +enum rtrs_imm_const {MAX_IMM_TYPE_BITS =4 ,MAX_IMM_TYPE_MASK = ((1 <<MAX_IMM_TYPE_BITS ) -1 ),
@@ -46,16 +57,6 @@ enum {MAX_PATHS_NUM =128 , -/* -* Max IB immediate data size is 2^28 (MAX_IMM_PAYL_BITS) -* and the minimum chunk size is 4096 (2^12). -* So the maximum sess_queue_depth is 65536 (2^16) in theory. -* But mempool_create, create_qp and ib_post_send fail with -* "cannot allocate memory" error if sess_queue_depth is too big. -* Therefore the pratical max value of sess_queue_depth is -* somewhere between 1 and 65534 and it depends on the system. -*/ -MAX_SESS_QUEUE_DEPTH =65535 ,MIN_CHUNK_SIZE =8192 , RTRS_HB_INTERVAL_MS = 5000,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 335/545 RDMA/qedr: Improve error logs for rdma_alloc_tid error return
In reply to Greg Kroah-HartmanFrom: Prabhakar Kushwaha <[email protected]>
[ Upstream commit 0050a57638ca4d681ff92bee55246bf64a6afe54 ]
Use -EINVAL return type to identify whether error is returned because of "Out of MR resources" or any other error types.
--- drivers/infiniband/hw/qedr/verbs.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/infiniband/hw/qedr/verbs.c +15 -3
@@ -2989,7 +2989,11 @@ struct ib_mr *qedr_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len, rc = dev->ops->rdma_alloc_tid (dev->rdma_ctx, &mr->hw_mr.itid);if (rc) { -DP_ERR (dev,"roce alloc tid returned an error %d\n" , rc); +if (rc == -EINVAL ) +DP_ERR (dev,"Out of MR resources\n" ); +else +DP_ERR (dev,"roce alloc tid returned error %d\n" , rc); + goto err1; }
@@ -3084,7 +3088,11 @@ static struct qedr_mr *__qedr_alloc_mr(struct ib_pd *ibpd, rc = dev->ops->rdma_alloc_tid (dev->rdma_ctx, &mr->hw_mr.itid);if (rc) { -DP_ERR (dev,"roce alloc tid returned an error %d\n" , rc); +if (rc == -EINVAL ) +DP_ERR (dev,"Out of MR resources\n" ); +else +DP_ERR (dev,"roce alloc tid returned error %d\n" , rc); + goto err0; }
@@ -3214,7 +3222,11 @@ struct ib_mr *qedr_get_dma_mr(struct ib_pd *ibpd, int acc) rc = dev->ops->rdma_alloc_tid (dev->rdma_ctx, &mr->hw_mr.itid);if (rc) { -DP_ERR (dev,"roce alloc tid returned an error %d\n" , rc); +if (rc == -EINVAL ) +DP_ERR (dev,"Out of MR resources\n" ); +else +DP_ERR (dev,"roce alloc tid returned error %d\n" , rc); + goto err1; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 336/545 RDMA/qedr: Fix potential memory leak in __qedr_alloc_mr()
In reply to Greg Kroah-HartmanFrom: Jianglei Nie <[email protected]>
[ Upstream commit b3236a64ddd125a455ef5b5316c1b9051b732974 ]
__qedr_alloc_mr() allocates a memory chunk for "mr->info.pbl_table" with init_mr_info(). When rdma_alloc_tid() and rdma_register_tid() fail, "mr" is released while "mr->info.pbl_table" is not released, which will lead to a memory leak.
We should release the "mr->info.pbl_table" with qedr_free_pbl() when error occurs to fix the memory leak.
--- drivers/infiniband/hw/qedr/verbs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/infiniband/hw/qedr/verbs.c +5 -3
@@ -3093,7 +3093,7 @@ static struct qedr_mr *__qedr_alloc_mr(struct ib_pd *ibpd,else DP_ERR (dev,"roce alloc tid returned error %d\n" , rc); - goto err0; + goto err1; }/* Index only, 18 bit long, lkey = itid << 8 | key */
@@ -3117,7 +3117,7 @@ static struct qedr_mr *__qedr_alloc_mr(struct ib_pd *ibpd, rc = dev->ops->rdma_register_tid (dev->rdma_ctx, &mr->hw_mr);if (rc) {DP_ERR (dev,"roce register tid returned an error %d\n" , rc); - goto err1; + goto err2; } mr->ibmr.lkey = mr->hw_mr.itid <<8 | mr->hw_mr.key;
@@ -3126,8 +3126,10 @@ static struct qedr_mr *__qedr_alloc_mr(struct ib_pd *ibpd,DP_DEBUG (dev,QEDR_MSG_MR ,"alloc frmr: %x\n" , mr->ibmr.lkey);return mr; -err1: +err2: dev->ops->rdma_free_tid (dev->rdma_ctx, mr->hw_mr.itid); +err1: +qedr_free_pbl (dev, &mr->info.pbl_info, mr->info.pbl_table); err0:kfree (mr);return ERR_PTR (rc);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 337/545 RDMA/hns: Fix incorrect clearing of interrupt status register
In reply to Greg Kroah-HartmanFrom: Haoyue Xu <[email protected]>
[ Upstream commit ecb4db5c3590aa956b4b2c352081a5b632d1f9f9 ]
The driver will clear all the interrupts in the same area when the driver handles the interrupt of type AEQ overflow. It should only set the interrupt status bit of type AEQ overflow.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +2 -2
@@ -5642,8 +5642,8 @@ static irqreturn_t hns_roce_v2_msix_interrupt_abn(int irq, void *dev_id)dev_err (dev,"AEQ overflow!\n" ); - int_st |=1 <<HNS_ROCE_V2_VF_INT_ST_AEQ_OVERFLOW_S ; -roce_write (hr_dev,ROCEE_VF_ABN_INT_ST_REG , int_st); +roce_write (hr_dev,ROCEE_VF_ABN_INT_ST_REG , +1 <<HNS_ROCE_V2_VF_INT_ST_AEQ_OVERFLOW_S );/* Set reset level for reset_event() */ if (ops->set_default_reset_request)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 338/545 RDMA/siw: Fix duplicated reported IW_CM_EVENT_CONNECT_REPLY event
In reply to Greg Kroah-HartmanFrom: Cheng Xu <[email protected]>
[ Upstream commit 3056fc6c32e613b760422b94c7617ac9a24a4721 ]
If siw_recv_mpa_rr returns -EAGAIN, it means that the MPA reply hasn't been received completely, and should not report IW_CM_EVENT_CONNECT_REPLY in this case. This may trigger a call trace in iw_cm. A simple way to trigger this:
server: ib_send_lat
client: ib_send_lat -R <server_ip>
The call trace looks like this:
kernel BUG at drivers/infiniband/core/iwcm.c:894! invalid opcode: 0000 [#1] PREEMPT SMP NOPTI <...>
Workqueue: iw_cm_wq cm_work_handler [iw_cm] Call Trace: <TASK> cm_work_handler+0x1dd/0x370 [iw_cm] process_one_work+0x1e2/0x3b0 worker_thread+0x49/0x2e0 ? rescuer_thread+0x370/0x370 kthread+0xe5/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x1f/0x30 </TASK>
--- drivers/infiniband/sw/siw/siw_cm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/infiniband/sw/siw/siw_cm.c +4 -3
@@ -725,11 +725,11 @@ static int siw_proc_mpareply(struct siw_cep *cep)enum mpa_v2_ctrl mpa_p2p_mode =MPA_V2_RDMA_NO_RTR ; rv =siw_recv_mpa_rr (cep); -if (rv != -EAGAIN ) -siw_cancel_mpatimer (cep);if (rv) goto out_err; +siw_cancel_mpatimer (cep); + rep = &cep->mpa.hdr;if (__mpa_rr_revision (rep->params.bits) >MPA_REVISION_2 ) {
@@ -895,7 +895,8 @@ static int siw_proc_mpareply(struct siw_cep *cep) } out_err: -siw_cm_upcall (cep,IW_CM_EVENT_CONNECT_REPLY , -EINVAL ); +if (rv != -EAGAIN ) +siw_cm_upcall (cep,IW_CM_EVENT_CONNECT_REPLY , -EINVAL );return rv; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 339/545 RDMA/hfi1: fix potential memory leak in setup_base_ctxt()
In reply to Greg Kroah-HartmanFrom: Jianglei Nie <[email protected]>
[ Upstream commit aa2a1df3a2c85f855af7d54466ac10bd48645d63 ]
setup_base_ctxt() allocates a memory chunk for uctxt->groups with hfi1_alloc_ctxt_rcv_groups(). When init_user_ctxt() fails, uctxt->groups is not released, which will lead to a memory leak.
We should release the uctxt->groups with hfi1_free_ctxt_rcv_groups() when init_user_ctxt() fails.
--- drivers/infiniband/hw/hfi1/file_ops.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hfi1/file_ops.c +3 -1
@@ -1220,8 +1220,10 @@ static int setup_base_ctxt(struct hfi1_filedata *fd, goto done; ret =init_user_ctxt (fd, uctxt); -if (ret) +if (ret) { +hfi1_free_ctxt_rcv_groups (uctxt); goto done; + }user_init (uctxt);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 340/545 gpio: gpiolib-of: Fix refcount bugs in of_mm_gpiochip_add_data()
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 5d07a692f9562f9c06e62cce369e9dd108173a0f ]
We should use of_node_get() when a new reference of device_node is created. It is noted that the old reference stored in 'mm_gc->gc.of_node' should also be decreased.
This patch is based on the fact that there is a call site in function 'qe_add_gpiochips()' of src file 'drivers\soc\fsl\qe\gpio.c'. In this function, of_mm_gpiochip_add_data() is contained in an iteration of for_each_compatible_node() which will automatically increase and decrease the refcount. So we need additional of_node_get() for the reference escape in of_mm_gpiochip_add_data().
--- drivers/gpio/gpiolib-of.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpio/gpiolib-of.c +3 -1
@@ -863,7 +863,8 @@ int of_mm_gpiochip_add_data(struct device_node *np,if (mm_gc->save_regs) mm_gc->save_regs (mm_gc); - mm_gc->gc.of_node = np; +of_node_put (mm_gc->gc.of_node); + mm_gc->gc.of_node =of_node_get (np); ret =gpiochip_add_data (gc, data);if (ret)
@@ -871,6 +872,7 @@ int of_mm_gpiochip_add_data(struct device_node *np,return 0 ; err2: +of_node_put (np);iounmap (mm_gc->regs); err1:kfree (gc->label);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 341/545 HID: mcp2221: prevent a buffer overflow in mcp_smbus_write()
In reply to Greg Kroah-HartmanFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit 62ac2473553a00229e67bdf3cb023b62cf7f5a9a ]
Smatch Warning:drivers/hid/hid-mcp2221.c:388 mcp_smbus_write() error: __memcpy() '&mcp->txbuf[5]' too small (59 vs 255) drivers/hid/hid-mcp2221.c:388 mcp_smbus_write() error: __memcpy() 'buf' too small (34 vs 255)
The 'len' variable can take a value between 0-255 as it can come from data->block[0] and it is user data. So add an bound check to prevent a buffer overflow in memcpy().
--- drivers/hid/hid-mcp2221.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hid/hid-mcp2221.c +3 -0
@@ -385,6 +385,9 @@ static int mcp_smbus_write(struct mcp2221 *mcp, u16 addr, data_len =7 ;break ;default : +if (len >I2C_SMBUS_BLOCK_MAX ) +return -EINVAL ; +memcpy (&mcp->txbuf[5 ], buf, len); data_len = len +5 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 342/545 mmc: cavium-octeon: Add of_node_put() when breaking out of loop
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 19bbb49acf8d7a03cb83e05624363741a4c3ec6f ]
In octeon_mmc_probe(), we should call of_node_put() when breaking out of for_each_child_of_node() which has increased and decreased the refcount during each iteration.
--- drivers/mmc/host/cavium-octeon.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/cavium-octeon.c +1 -0
@@ -277,6 +277,7 @@ static int octeon_mmc_probe(struct platform_device *pdev)if (ret) {dev_err (&pdev->dev,"Error populating slots\n" );octeon_mmc_set_shared_power (host,0 ); +of_node_put (cn); goto error; } i++;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 343/545 mmc: cavium-thunderx: Add of_node_put() when breaking out of loop
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 7ee480795e41db314f2c445c65ed854a5d6e8e32 ]
In thunder_mmc_probe(), we should call of_node_put() when breaking out of for_each_child_of_node() which has increased and decreased the refcount during each iteration.
--- drivers/mmc/host/cavium-thunderx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/cavium-thunderx.c +3 -1
@@ -142,8 +142,10 @@ static int thunder_mmc_probe(struct pci_dev *pdev,continue ; ret =cvm_mmc_of_slot_probe (&host->slot_pdev[i]->dev, host); -if (ret) +if (ret) { +of_node_put (child_node); goto error; + } } i++; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 344/545 HID: alps: Declare U1_UNICORN_LEGACY support
In reply to Greg Kroah-HartmanFrom: Artem Borisov <[email protected]>
[ Upstream commit 1117d182c5d72abd7eb8b7d5e7b8c3373181c3ab ]
U1_UNICORN_LEGACY id was added to the driver, but was not declared in the device id table, making it impossible to use.
--- drivers/hid/hid-alps.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hid/hid-alps.c +2 -0
@@ -830,6 +830,8 @@ static const struct hid_device_id alps_id[] = { USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1_DUAL) }, { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1) }, + { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, + USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1_UNICORN_LEGACY) }, { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_T4_BTNLESS) }, { }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 345/545 PCI: tegra194: Fix Root Port interrupt handling
In reply to Greg Kroah-HartmanFrom: Vidya Sagar <[email protected]>
[ Upstream commit 6646e99bcec627e866bc84365af37942c72b4b76 ]
As part of Root Port interrupt handling, level-0 register is read first and based on the bits set in that, corresponding level-1 registers are read for further interrupt processing. Since both these values are currently read into the same 'val' variable, checking level-0 bits the second time around is happening on the 'val' variable value of level-1 register contents instead of freshly reading the level-0 value again.
Fix by using different variables to store level-0 and level-1 registers contents.
--- drivers/pci/controller/dwc/pcie-tegra194.c | 46 +++++++++++----------- 1 file changed, 22 insertions(+), 24 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +22 -24
@@ -370,15 +370,14 @@ static irqreturn_t tegra_pcie_rp_irq_handler(int irq, void *arg)struct tegra_pcie_dw *pcie = arg;struct dw_pcie *pci = &pcie->pci;struct pcie_port *pp = &pci->pp; -u32 val, tmp; +u32 val, status_l0, status_l1;u16 val_w; - val =appl_readl (pcie,APPL_INTR_STATUS_L0 ); -if (val &APPL_INTR_STATUS_L0_LINK_STATE_INT ) { - val =appl_readl (pcie,APPL_INTR_STATUS_L1_0_0 ); -if (val &APPL_INTR_STATUS_L1_0_0_LINK_REQ_RST_NOT_CHGED ) { -appl_writel (pcie, val,APPL_INTR_STATUS_L1_0_0 ); - + status_l0 =appl_readl (pcie,APPL_INTR_STATUS_L0 ); +if (status_l0 &APPL_INTR_STATUS_L0_LINK_STATE_INT ) { + status_l1 =appl_readl (pcie,APPL_INTR_STATUS_L1_0_0 ); +appl_writel (pcie, status_l1,APPL_INTR_STATUS_L1_0_0 ); +if (status_l1 &APPL_INTR_STATUS_L1_0_0_LINK_REQ_RST_NOT_CHGED ) {/* SBR & Surprise Link Down WAR */ val =appl_readl (pcie,APPL_CAR_RESET_OVRD ); val &= ~APPL_CAR_RESET_OVRD_CYA_OVERRIDE_CORE_RST_N ;
@@ -394,15 +393,15 @@ static irqreturn_t tegra_pcie_rp_irq_handler(int irq, void *arg) } } -if (val &APPL_INTR_STATUS_L0_INT_INT ) { - val =appl_readl (pcie,APPL_INTR_STATUS_L1_8_0 ); -if (val &APPL_INTR_STATUS_L1_8_0_AUTO_BW_INT_STS ) { +if (status_l0 &APPL_INTR_STATUS_L0_INT_INT ) { + status_l1 =appl_readl (pcie,APPL_INTR_STATUS_L1_8_0 ); +if (status_l1 &APPL_INTR_STATUS_L1_8_0_AUTO_BW_INT_STS ) {appl_writel (pcie,APPL_INTR_STATUS_L1_8_0_AUTO_BW_INT_STS ,APPL_INTR_STATUS_L1_8_0 );apply_bad_link_workaround (pp); } -if (val &APPL_INTR_STATUS_L1_8_0_BW_MGT_INT_STS ) { +if (status_l1 &APPL_INTR_STATUS_L1_8_0_BW_MGT_INT_STS ) {appl_writel (pcie,APPL_INTR_STATUS_L1_8_0_BW_MGT_INT_STS ,APPL_INTR_STATUS_L1_8_0 );
@@ -414,25 +413,24 @@ static irqreturn_t tegra_pcie_rp_irq_handler(int irq, void *arg) } } - val =appl_readl (pcie,APPL_INTR_STATUS_L0 ); -if (val &APPL_INTR_STATUS_L0_CDM_REG_CHK_INT ) { - val =appl_readl (pcie,APPL_INTR_STATUS_L1_18 ); - tmp =dw_pcie_readl_dbi (pci,PCIE_PL_CHK_REG_CONTROL_STATUS ); -if (val &APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMPLT ) { +if (status_l0 &APPL_INTR_STATUS_L0_CDM_REG_CHK_INT ) { + status_l1 =appl_readl (pcie,APPL_INTR_STATUS_L1_18 ); + val =dw_pcie_readl_dbi (pci,PCIE_PL_CHK_REG_CONTROL_STATUS ); +if (status_l1 &APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMPLT ) {dev_info (pci->dev,"CDM check complete\n" ); - tmp |=PCIE_PL_CHK_REG_CHK_REG_COMPLETE ; + val |=PCIE_PL_CHK_REG_CHK_REG_COMPLETE ; } -if (val &APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMP_ERR ) { +if (status_l1 &APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMP_ERR ) {dev_err (pci->dev,"CDM comparison mismatch\n" ); - tmp |=PCIE_PL_CHK_REG_CHK_REG_COMPARISON_ERROR ; + val |=PCIE_PL_CHK_REG_CHK_REG_COMPARISON_ERROR ; } -if (val &APPL_INTR_STATUS_L1_18_CDM_REG_CHK_LOGIC_ERR ) { +if (status_l1 &APPL_INTR_STATUS_L1_18_CDM_REG_CHK_LOGIC_ERR ) {dev_err (pci->dev,"CDM Logic error\n" ); - tmp |=PCIE_PL_CHK_REG_CHK_REG_LOGIC_ERROR ; + val |=PCIE_PL_CHK_REG_CHK_REG_LOGIC_ERROR ; } -dw_pcie_writel_dbi (pci,PCIE_PL_CHK_REG_CONTROL_STATUS , tmp); - tmp =dw_pcie_readl_dbi (pci,PCIE_PL_CHK_REG_ERR_ADDR ); -dev_err (pci->dev,"CDM Error Address Offset = 0x%08X\n" , tmp); +dw_pcie_writel_dbi (pci,PCIE_PL_CHK_REG_CONTROL_STATUS , val); + val =dw_pcie_readl_dbi (pci,PCIE_PL_CHK_REG_ERR_ADDR ); +dev_err (pci->dev,"CDM Error Address Offset = 0x%08X\n" , val); }return IRQ_HANDLED ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 346/545 PCI: tegra194: Fix link up retry sequence
In reply to Greg Kroah-HartmanFrom: Vidya Sagar <[email protected]>
[ Upstream commit e05fd6ae77c3e2cc0dba283005d24b6d56d2b1fa ]
Add the missing DLF capability offset while clearing DL_FEATURE_EXCHANGE_EN bit during link up retry.
--- drivers/pci/controller/dwc/pcie-tegra194.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-tegra194.c +1 -1
@@ -963,7 +963,7 @@ static int tegra_pcie_dw_host_init(struct pcie_port *pp) offset =dw_pcie_find_ext_capability (pci,PCI_EXT_CAP_ID_DLF ); val =dw_pcie_readl_dbi (pci, offset +PCI_DLF_CAP ); val &= ~PCI_DLF_EXCHANGE_ENABLE ; -dw_pcie_writel_dbi (pci, offset, val); +dw_pcie_writel_dbi (pci, offset +PCI_DLF_CAP , val);tegra_pcie_prepare_host (pp);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 347/545 USB: serial: fix tty-port initialized comments
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 688ee1d1785c1359f9040f615dd8e6054962bce2 ]
Fix up the tty-port initialized comments which got truncated and obfuscated when replacing the old ASYNCB_INITIALIZED flag.
--- drivers/usb/serial/sierra.c | 3 ++- drivers/usb/serial/usb-serial.c | 2 +- drivers/usb/serial/usb_wwan.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-)
drivers/usb/serial/sierra.c +2 -1
@@ -737,7 +737,8 @@ static void sierra_close(struct usb_serial_port *port)/* * Need to take susp_lock to make sure port is not already being -* resumed, but no need to hold it due to initialized +* resumed, but no need to hold it due to the tty-port initialized +* flag. */ spin_lock_irq (&intfdata->susp_lock);if (--intfdata->open_ports ==0 )
drivers/usb/serial/usb-serial.c +1 -1
@@ -254,7 +254,7 @@ static int serial_open(struct tty_struct *tty, struct file *filp)* * Shut down a USB serial port. Serialized against activate by the * tport mutex and kept to matching open/close pairs -* of calls by the initialized flag. +* of calls by the tty-port initialized flag. * * Not called if tty is console. */
drivers/usb/serial/usb_wwan.c +2 -1
@@ -435,7 +435,8 @@ void usb_wwan_close(struct usb_serial_port *port)/* * Need to take susp_lock to make sure port is not already being -* resumed, but no need to hold it due to initialized +* resumed, but no need to hold it due to the tty-port initialized +* flag. */ spin_lock_irq (&intfdata->susp_lock);if (--intfdata->open_ports ==0 )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 348/545 usb: cdns3: change place of priv_ep assignment in cdns3_gadget_ep_dequeue(), cdns3_gadget_ep_enable()
In reply to Greg Kroah-HartmanFrom: Andrey Strachuk <[email protected]>
[ Upstream commit c3ffc9c4ca44bfe9562166793d133e1fb0630ea6 ]
If 'ep' is NULL, result of ep_to_cdns3_ep(ep) is invalid pointer and its dereference with priv_ep->cdns3_dev may cause panic.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/usb/cdns3/gadget.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/cdns3/gadget.c +6 -3
@@ -2294,14 +2294,15 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep,int val; priv_ep =ep_to_cdns3_ep (ep); - priv_dev = priv_ep->cdns3_dev; - comp_desc = priv_ep->endpoint.comp_desc;if (!ep || !desc || desc->bDescriptorType !=USB_DT_ENDPOINT ) {dev_dbg (priv_dev->dev,"usbss: invalid parameters\n" );return -EINVAL ; } + comp_desc = priv_ep->endpoint.comp_desc; + priv_dev = priv_ep->cdns3_dev; +if (!desc->wMaxPacketSize) {dev_err (priv_dev->dev,"usbss: missing wMaxPacketSize\n" );return -EINVAL ;
@@ -2609,7 +2610,7 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep, struct usb_request *request) {struct cdns3_endpoint *priv_ep =ep_to_cdns3_ep (ep); -struct cdns3_device *priv_dev = priv_ep->cdns3_dev; +struct cdns3_device *priv_dev;struct usb_request *req, *req_temp;struct cdns3_request *priv_req;struct cdns3_trb *link_trb;
@@ -2620,6 +2621,8 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,if (!ep || !request || !ep->desc)return -EINVAL ; + priv_dev = priv_ep->cdns3_dev; +spin_lock_irqsave (&priv_dev->lock, flags); priv_req =to_cdns3_request (request);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 349/545 platform/olpc: Fix uninitialized data in debugfs write
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 40ec787e1adf302c11668d4cc69838f4d584187d ]
The call to:
size = simple_write_to_buffer(cmdbuf, sizeof(cmdbuf), ppos, buf, size);
will succeed if at least one byte is written to the "cmdbuf" buffer. The "*ppos" value controls which byte is written. Another problem is that this code does not check for errors so it's possible for the entire buffer to be uninitialized.
Inintialize the struct to zero to prevent reading uninitialized stack data.
Debugfs is normally only writable by root so the impact of this bug is very minimal.
--- drivers/platform/olpc/olpc-ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/olpc/olpc-ec.c +1 -1
@@ -265,7 +265,7 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,int i, m;unsigned char ec_cmd[EC_MAX_CMD_ARGS ];unsigned int ec_cmd_int[EC_MAX_CMD_ARGS ]; -char cmdbuf[64 ]; +char cmdbuf[64 ] ="" ;int ec_cmd_bytes;mutex_lock (&ec_dbgfs_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 350/545 RDMA/srpt: Duplicate port name members
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
[ Upstream commit b03b1ae2a3125d4475452e4f19f5d3a6e910ff6e ]
Prepare for decoupling the lifetimes of struct srpt_port and struct srpt_port_id by duplicating the port name into struct srpt_port.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 9 ++++++--- drivers/infiniband/ulp/srpt/ib_srpt.h | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +6 -3
@@ -566,14 +566,17 @@ static int srpt_refresh_port(struct srpt_port *sport)return ret; sport->port_guid_id.wwn.priv = sport; -srpt_format_guid (sport->port_guid_id.name, -sizeof (sport->port_guid_id.name), +srpt_format_guid (sport->guid_name,ARRAY_SIZE (sport->guid_name), &sport->gid.global.interface_id); +memcpy (sport->port_guid_id.name, sport->guid_name, +ARRAY_SIZE (sport->guid_name)); sport->port_gid_id.wwn.priv = sport; -snprintf (sport->port_gid_id.name,sizeof (sport->port_gid_id.name), +snprintf (sport->gid_name,ARRAY_SIZE (sport->gid_name),"0x%016llx%016llx" ,be64_to_cpu (sport->gid.global.subnet_prefix),be64_to_cpu (sport->gid.global.interface_id)); +memcpy (sport->port_gid_id.name, sport->gid_name, +ARRAY_SIZE (sport->gid_name));if (rdma_protocol_iwarp (sport->sdev->device, sport->port))return 0 ;
drivers/infiniband/ulp/srpt/ib_srpt.h +7 -3
@@ -376,7 +376,7 @@ struct srpt_tpg { };/** -* struct srpt_port_id - information about an RDMA port name +* struct srpt_port_id - LIO RDMA port information * @mutex: Protects @tpg_list changes. * @tpg_list: TPGs associated with the RDMA port name. * @wwn: WWN associated with the RDMA port name.
@@ -402,8 +402,10 @@ struct srpt_port_id {* @lid: cached value of the port's lid. * @gid: cached value of the port's gid. * @work: work structure for refreshing the aforementioned cached values. -* @port_guid_id: target port GUID -* @port_gid_id: target port GID +* @guid_name: port name in GUID format. +* @port_guid_id: LIO target port information for the port name in GUID format. +* @gid_name: port name in GID format. +* @port_gid_id: LIO target port information for the port name in GID format. * @port_attrib: Port attributes that can be accessed through configfs. * @refcount: Number of objects associated with this port. * @freed_channels: Completion that will be signaled once @refcount becomes 0.
@@ -419,7 +421,9 @@ struct srpt_port {u32 lid;union ib_gid gid;struct work_struct work; +char guid_name[64 ];struct srpt_port_id port_guid_id; +char gid_name[64 ];struct srpt_port_id port_gid_id;struct srpt_port_attrib port_attrib;atomic_t refcount;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 351/545 RDMA/srpt: Introduce a reference count in struct srpt_device
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
[ Upstream commit aa7dfbb41b5a60ab90e244d6f586b8cb5c791c3e ]
This will be used to keep struct srpt_device around as long as either the RDMA port exists or a LIO target port is associated with the struct srpt_device.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 17 +++++++++++++++-- drivers/infiniband/ulp/srpt/ib_srpt.h | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +15 -2
@@ -3101,6 +3101,18 @@ static int srpt_use_srq(struct srpt_device *sdev, bool use_srq)return ret; } +static void srpt_free_sdev (struct kref *refcnt) +{ +struct srpt_device *sdev =container_of (refcnt,typeof (*sdev), refcnt); + +kfree (sdev); +} + +static void srpt_sdev_put (struct srpt_device *sdev) +{ +kref_put (&sdev->refcnt, srpt_free_sdev); +} +/** * srpt_add_one - InfiniBand device addition callback function * @device: Describes a HCA.
@@ -3118,6 +3130,7 @@ static int srpt_add_one(struct ib_device *device)if (!sdev)return -ENOMEM ; +kref_init (&sdev->refcnt); sdev->device = device;mutex_init (&sdev->sdev_mutex);
@@ -3213,7 +3226,7 @@ static int srpt_add_one(struct ib_device *device)srpt_free_srq (sdev);ib_dealloc_pd (sdev->pd); free_dev: -kfree (sdev); +srpt_sdev_put (sdev);pr_info ("%s(%s) failed.\n" , __func__,dev_name (&device->dev));return ret; }
@@ -3257,7 +3270,7 @@ static void srpt_remove_one(struct ib_device *device, void *client_data)ib_dealloc_pd (sdev->pd); -kfree (sdev); +srpt_sdev_put (sdev); }static struct ib_client srpt_client = {
drivers/infiniband/ulp/srpt/ib_srpt.h +2 -0
@@ -434,6 +434,7 @@ struct srpt_port {/** * struct srpt_device - information associated by SRPT with a single HCA +* @refcnt: Reference count for this device. * @device: Backpointer to the struct ib_device managed by the IB core. * @pd: IB protection domain. * @lkey: L_Key (local key) with write access to all local memory.
@@ -449,6 +450,7 @@ struct srpt_port {* @port: Information about the ports owned by this HCA. */ struct srpt_device { +struct kref refcnt;struct ib_device *device;struct ib_pd *pd;u32 lkey;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 352/545 RDMA/srpt: Fix a use-after-free
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
[ Upstream commit b5605148e6ce36bb21020d49010b617693933128 ]
Change the LIO port members inside struct srpt_port from regular members into pointers. Allocate the LIO port data structures from inside srpt_make_tport() and free these from inside srpt_make_tport(). Keep struct srpt_device as long as either an RDMA port or a LIO target port is associated with it. This patch decouples the lifetime of struct srpt_port (controlled by the RDMA core) and struct srpt_port_id (controlled by LIO). This patch fixes the following KASAN complaint:
BUG: KASAN: use-after-free in srpt_enable_tpg+0x31/0x70 [ib_srpt] Read of size 8 at addr ffff888141cc34b8 by task check/5093 Call Trace: <TASK> show_stack+0x4e/0x53 dump_stack_lvl+0x51/0x66 print_address_description.constprop.0.cold+0xea/0x41e print_report.cold+0x90/0x205 kasan_report+0xb9/0xf0 __asan_load8+0x69/0x90 srpt_enable_tpg+0x31/0x70 [ib_srpt] target_fabric_tpg_base_enable_store+0xe2/0x140 [target_core_mod] configfs_write_iter+0x18b/0x210 new_sync_write+0x1f2/0x2f0 vfs_write+0x3e3/0x540 ksys_write+0xbb/0x140 __x64_sys_write+0x42/0x50 do_syscall_64+0x34/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 </TASK>
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 130 ++++++++++++++++++-------- drivers/infiniband/ulp/srpt/ib_srpt.h | 10 +- 2 files changed, 94 insertions(+), 46 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +89 -41
@@ -565,18 +565,12 @@ static int srpt_refresh_port(struct srpt_port *sport)if (ret)return ret; - sport->port_guid_id.wwn.priv = sport;srpt_format_guid (sport->guid_name,ARRAY_SIZE (sport->guid_name), &sport->gid.global.interface_id); -memcpy (sport->port_guid_id.name, sport->guid_name, -ARRAY_SIZE (sport->guid_name)); - sport->port_gid_id.wwn.priv = sport;snprintf (sport->gid_name,ARRAY_SIZE (sport->gid_name),"0x%016llx%016llx" ,be64_to_cpu (sport->gid.global.subnet_prefix),be64_to_cpu (sport->gid.global.interface_id)); -memcpy (sport->port_gid_id.name, sport->gid_name, -ARRAY_SIZE (sport->gid_name));if (rdma_protocol_iwarp (sport->sdev->device, sport->port))return 0 ;
@@ -2313,31 +2307,35 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev, tag_num = ch->rq_size; tag_size =1 ;/* ib_srpt does not use se_sess->sess_cmd_map */ -mutex_lock (&sport->port_guid_id.mutex); -list_for_each_entry (stpg, &sport->port_guid_id.tpg_list, entry) { -if (!IS_ERR_OR_NULL (ch->sess)) -break ; - ch->sess =target_setup_session (&stpg->tpg, tag_num, +if (sport->guid_id) { +mutex_lock (&sport->guid_id->mutex); +list_for_each_entry (stpg, &sport->guid_id->tpg_list, entry) { +if (!IS_ERR_OR_NULL (ch->sess)) +break ; + ch->sess =target_setup_session (&stpg->tpg, tag_num, tag_size,TARGET_PROT_NORMAL , ch->sess_name, ch,NULL ); + } +mutex_unlock (&sport->guid_id->mutex); } -mutex_unlock (&sport->port_guid_id.mutex); -mutex_lock (&sport->port_gid_id.mutex); -list_for_each_entry (stpg, &sport->port_gid_id.tpg_list, entry) { -if (!IS_ERR_OR_NULL (ch->sess)) -break ; - ch->sess =target_setup_session (&stpg->tpg, tag_num, +if (sport->gid_id) { +mutex_lock (&sport->gid_id->mutex); +list_for_each_entry (stpg, &sport->gid_id->tpg_list, entry) { +if (!IS_ERR_OR_NULL (ch->sess)) +break ; + ch->sess =target_setup_session (&stpg->tpg, tag_num, tag_size,TARGET_PROT_NORMAL , i_port_id, ch,NULL ); -if (!IS_ERR_OR_NULL (ch->sess)) -break ; -/* Retry without leading "0x" */ - ch->sess =target_setup_session (&stpg->tpg, tag_num, +if (!IS_ERR_OR_NULL (ch->sess)) +break ; +/* Retry without leading "0x" */ + ch->sess =target_setup_session (&stpg->tpg, tag_num, tag_size,TARGET_PROT_NORMAL , i_port_id +2 , ch,NULL ); + } +mutex_unlock (&sport->gid_id->mutex); } -mutex_unlock (&sport->port_gid_id.mutex);if (IS_ERR_OR_NULL (ch->sess)) {WARN_ON_ONCE (ch->sess ==NULL );
@@ -2983,7 +2981,12 @@ static int srpt_release_sport(struct srpt_port *sport)return 0 ; } -static struct se_wwn *__srpt_lookup_wwn (const char *name) +struct port_and_port_id { +struct srpt_port *sport; +struct srpt_port_id **port_id; +}; + +static struct port_and_port_id __srpt_lookup_port (const char *name) {struct ib_device *dev;struct srpt_device *sdev;
@@ -2998,25 +3001,38 @@ static struct se_wwn *__srpt_lookup_wwn(const char *name)for (i =0 ; i < dev->phys_port_cnt; i++) { sport = &sdev->port[i]; -if (strcmp (sport->port_guid_id.name, name) ==0 ) -return &sport->port_guid_id.wwn; -if (strcmp (sport->port_gid_id.name, name) ==0 ) -return &sport->port_gid_id.wwn; +if (strcmp (sport->guid_name, name) ==0 ) { +kref_get (&sdev->refcnt); +return (struct port_and_port_id ){ + sport, &sport->guid_id}; + } +if (strcmp (sport->gid_name, name) ==0 ) { +kref_get (&sdev->refcnt); +return (struct port_and_port_id ){ + sport, &sport->gid_id}; + } } } -return NULL ; +return (struct port_and_port_id ){}; } -static struct se_wwn *srpt_lookup_wwn (const char *name) +/** +* srpt_lookup_port() - Look up an RDMA port by name +* @name: ASCII port name +* +* Increments the RDMA port reference count if an RDMA port pointer is returned. +* The caller must drop that reference count by calling srpt_port_put_ref(). +*/ +static struct port_and_port_id srpt_lookup_port (const char *name) { -struct se_wwn *wwn; +struct port_and_port_id papi;spin_lock (&srpt_dev_lock); - wwn =__srpt_lookup_wwn (name); + papi =__srpt_lookup_port (name);spin_unlock (&srpt_dev_lock); -return wwn; +return papi; }static void srpt_free_srq (struct srpt_device *sdev)
@@ -3194,10 +3210,6 @@ static int srpt_add_one(struct ib_device *device) sport->port_attrib.srp_sq_size =DEF_SRPT_SQ_SIZE ; sport->port_attrib.use_srq = false;INIT_WORK (&sport->work, srpt_refresh_port_work); -mutex_init (&sport->port_guid_id.mutex); -INIT_LIST_HEAD (&sport->port_guid_id.tpg_list); -mutex_init (&sport->port_gid_id.mutex); -INIT_LIST_HEAD (&sport->port_gid_id.tpg_list); ret =srpt_refresh_port (sport);if (ret) {
@@ -3298,10 +3310,10 @@ static struct srpt_port_id *srpt_wwn_to_sport_id(struct se_wwn *wwn) {struct srpt_port *sport = wwn->priv; -if (wwn == &sport->port_guid_id.wwn) -return &sport->port_guid_id; -if (wwn == &sport->port_gid_id.wwn) -return &sport->port_gid_id; +if (sport->guid_id && &sport->guid_id->wwn == wwn) +return sport->guid_id; +if (sport->gid_id && &sport->gid_id->wwn == wwn) +return sport->gid_id;WARN_ON_ONCE (true);return NULL ; }
@@ -3816,7 +3828,31 @@ static struct se_wwn *srpt_make_tport(struct target_fabric_configfs *tf,struct config_group *group, const char *name) { - return srpt_lookup_wwn(name) ? : ERR_PTR(-EINVAL); + struct port_and_port_id papi = srpt_lookup_port(name); +struct srpt_port *sport = papi.sport; +struct srpt_port_id *port_id; + +if (!papi.port_id) +return ERR_PTR (-EINVAL ); +if (*papi.port_id) { +/* Attempt to create a directory that already exists. */ +WARN_ON_ONCE (true); +return &(*papi.port_id)->wwn; + } + port_id =kzalloc (sizeof (*port_id),GFP_KERNEL ); +if (!port_id) { +srpt_sdev_put (sport->sdev); +return ERR_PTR (-ENOMEM ); + } +mutex_init (&port_id->mutex); +INIT_LIST_HEAD (&port_id->tpg_list); + port_id->wwn.priv = sport; +memcpy (port_id->name, port_id == sport->guid_id ? sport->guid_name : + sport->gid_name,ARRAY_SIZE (port_id->name)); + + *papi.port_id = port_id; + +return &port_id->wwn; }/**
@@ -3825,6 +3861,18 @@ static struct se_wwn *srpt_make_tport(struct target_fabric_configfs *tf,*/ static void srpt_drop_tport (struct se_wwn *wwn) { +struct srpt_port_id *port_id =container_of (wwn,typeof (*port_id), wwn); +struct srpt_port *sport = wwn->priv; + +if (sport->guid_id == port_id) + sport->guid_id =NULL ; +else if (sport->gid_id == port_id) + sport->gid_id =NULL ; +else +WARN_ON_ONCE (true); + +srpt_sdev_put (sport->sdev); +kfree (port_id); }static ssize_t srpt_wwn_version_show (struct config_item *item,char *buf)
drivers/infiniband/ulp/srpt/ib_srpt.h +5 -5
@@ -393,7 +393,7 @@ struct srpt_port_id { };/** -* struct srpt_port - information associated by SRPT with a single IB port +* struct srpt_port - SRPT RDMA port information * @sdev: backpointer to the HCA information. * @mad_agent: per-port management datagram processing information. * @enabled: Whether or not this target port is enabled.
@@ -403,9 +403,9 @@ struct srpt_port_id {* @gid: cached value of the port's gid. * @work: work structure for refreshing the aforementioned cached values. * @guid_name: port name in GUID format. -* @port_guid_id: LIO target port information for the port name in GUID format. +* @guid_id: LIO target port information for the port name in GUID format. * @gid_name: port name in GID format. -* @port_gid_id: LIO target port information for the port name in GID format. +* @gid_id: LIO target port information for the port name in GID format. * @port_attrib: Port attributes that can be accessed through configfs. * @refcount: Number of objects associated with this port. * @freed_channels: Completion that will be signaled once @refcount becomes 0.
@@ -422,9 +422,9 @@ struct srpt_port {union ib_gid gid;struct work_struct work;char guid_name[64 ]; -struct srpt_port_id port_guid_id; +struct srpt_port_id *guid_id;char gid_name[64 ]; -struct srpt_port_id port_gid_id; +struct srpt_port_id *gid_id;struct srpt_port_attrib port_attrib;atomic_t refcount;struct completion *freed_channels;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 353/545 mm/mmap.c: fix missing call to vm_unacct_memory in mmap_region
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
[ Upstream commit 7f82f922319ede486540e8746769865b9508d2c2 ]
Since the beginning, charged is set to 0 to avoid calling vm_unacct_memory twice because vm_unacct_memory will be called by above unmap_region. But since commit 4f74d2c8e827 ("vm: remove 'nr_accounted' calculations from the unmap_vmas() interfaces"), unmap_region doesn't call vm_unacct_memory anymore. So charged shouldn't be set to 0 now otherwise the calling to paired vm_unacct_memory will be missed and leads to imbalanced account.
--- mm/mmap.c | 1 - 1 file changed, 1 deletion(-)
mm/mmap.c +0 -1
@@ -1902,7 +1902,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr,/* Undo any partial mapping done by a device driver. */ unmap_region (mm, vma, prev, vma->vm_start, vma->vm_end); - charged =0 ;if (vm_flags &VM_SHARED )mapping_unmap_writable (file->f_mapping); allow_write_and_free_vma:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 354/545 selftests: kvm: set rax before vmcall
In reply to Greg Kroah-HartmanFrom: Andrei Vagin <[email protected]>
[ Upstream commit 281106f938d3daaea6f8b6723a8217a2a1ef6936 ]
kvm_hypercall has to place the hypercall number in rax.
Trace events show that kvm_pv_test doesn't work properly:
kvm_pv_test-53132: kvm_hypercall: nr 0x0 a0 0x0 a1 0x0 a2 0x0 a3 0x0
kvm_pv_test-53132: kvm_hypercall: nr 0x0 a0 0x0 a1 0x0 a2 0x0 a3 0x0
kvm_pv_test-53132: kvm_hypercall: nr 0x0 a0 0x0 a1 0x0 a2 0x0 a3 0x0With this change, it starts working as expected:
kvm_pv_test-54285: kvm_hypercall: nr 0x5 a0 0x0 a1 0x0 a2 0x0 a3 0x0
kvm_pv_test-54285: kvm_hypercall: nr 0xa a0 0x0 a1 0x0 a2 0x0 a3 0x0
kvm_pv_test-54285: kvm_hypercall: nr 0xb a0 0x0 a1 0x0 a2 0x0 a3 0x0Message-Id: <[email protected]>
--- tools/testing/selftests/kvm/lib/x86_64/processor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/lib/x86_64/processor.c +1 -1
@@ -1253,6 +1253,6 @@ uint64_t kvm_hypercall(uint64_t nr, uint64_t a0, uint64_t a1, uint64_t a2, asmvolatile ("vmcall" :"=a" (r) - :"b" (a0),"c" (a1),"d" (a2),"S" (a3)); + :"a" (nr),"b" (a0),"c" (a1),"d" (a2),"S" (a3));return r; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 355/545 RDMA/mlx5: Add missing check for return value in get namespace flow
In reply to Greg Kroah-HartmanFrom: Maor Gottlieb <[email protected]>
[ Upstream commit c9776457bd5eaad4ce4ecb17af8d8f3cc6957c0b ]
Add missing check for return value when calling to mlx5_ib_ft_type_to_namespace, even though it can't really fail in this specific call.
--- drivers/infiniband/hw/mlx5/fs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/fs.c +2 -4
@@ -2081,12 +2081,10 @@ static int mlx5_ib_matcher_ns(struct uverbs_attr_bundle *attrs,if (err)return err; -if (flags) { -mlx5_ib_ft_type_to_namespace ( +if (flags) +return mlx5_ib_ft_type_to_namespace (MLX5_IB_UAPI_FLOW_TABLE_TYPE_NIC_TX , &obj->ns_type); -return 0 ; - } } obj->ns_type =MLX5_FLOW_NAMESPACE_BYPASS ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 356/545 RDMA/rxe: Fix error unwind in rxe_create_qp()
In reply to Greg Kroah-HartmanFrom: Zhu Yanjun <[email protected]>
[ Upstream commit fd5382c5805c4bcb50fd25b7246247d3f7114733 ]
In the function rxe_create_qp(), rxe_qp_from_init() is called to initialize qp, internally things like the spin locks are not setup until rxe_qp_init_req().
If an error occures before this point then the unwind will call rxe_cleanup() and eventually to rxe_qp_do_cleanup()/rxe_cleanup_task() which will oops when trying to access the uninitialized spinlock.
Move the spinlock initializations earlier before any failures.
--- drivers/infiniband/sw/rxe/rxe_qp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/infiniband/sw/rxe/rxe_qp.c +8 -4
@@ -184,6 +184,14 @@ static void rxe_qp_init_misc(struct rxe_dev *rxe, struct rxe_qp *qp,spin_lock_init (&qp->grp_lock);spin_lock_init (&qp->state_lock); +spin_lock_init (&qp->req.task.state_lock); +spin_lock_init (&qp->resp.task.state_lock); +spin_lock_init (&qp->comp.task.state_lock); + +spin_lock_init (&qp->sq.sq_lock); +spin_lock_init (&qp->rq.producer_lock); +spin_lock_init (&qp->rq.consumer_lock); +atomic_set (&qp->ssn,0 );atomic_set (&qp->skb_out,0 ); }
@@ -239,7 +247,6 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp, qp->req.opcode =-1 ; qp->comp.opcode =-1 ; -spin_lock_init (&qp->sq.sq_lock);skb_queue_head_init (&qp->req_pkts); rxe_init_task(rxe, &qp->req.task, qp,
@@ -289,9 +296,6 @@ static int rxe_qp_init_resp(struct rxe_dev *rxe, struct rxe_qp *qp, } } -spin_lock_init (&qp->rq.producer_lock); -spin_lock_init (&qp->rq.consumer_lock); -skb_queue_head_init (&qp->resp_pkts); rxe_init_task(rxe, &qp->resp.task, qp,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 357/545 null_blk: fix ida error handling in null_add_dev()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit ee452a8d984f94fa8e894f003a52e776e4572881 ]
There needs to be some error checking if ida_simple_get() fails. Also call ida_free() if there are errors later.
--- drivers/block/null_blk_main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/block/null_blk_main.c +11 -3
@@ -1876,8 +1876,13 @@ static int null_add_dev(struct nullb_device *dev)blk_queue_flag_clear (QUEUE_FLAG_ADD_RANDOM , nullb->q);mutex_lock (&lock); - nullb->index =ida_simple_get (&nullb_indexes,0 ,0 ,GFP_KERNEL ); - dev->index = nullb->index; + rv =ida_simple_get (&nullb_indexes,0 ,0 ,GFP_KERNEL ); +if (rv <0 ) { +mutex_unlock (&lock); + goto out_cleanup_zone; + } + nullb->index = rv; + dev->index = rv;mutex_unlock (&lock);blk_queue_logical_block_size (nullb->q, dev->blocksize);
@@ -1889,13 +1894,16 @@ static int null_add_dev(struct nullb_device *dev) rv =null_gendisk_register (nullb);if (rv) - goto out_cleanup_zone; + goto out_ida_free;mutex_lock (&lock);list_add_tail (&nullb->list, &nullb_list);mutex_unlock (&lock);return 0 ; + +out_ida_free: +ida_free (&nullb_indexes, nullb->index); out_cleanup_zone:null_free_zoned_dev (dev); out_cleanup_blk_queue:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 358/545 nvme: use command_id instead of req->tag in trace_nvme_complete_rq()
In reply to Greg Kroah-HartmanFrom: Bean Huo <[email protected]>
[ Upstream commit 679c54f2de672b7d79d02f8c4ad483ff6dd8ce2e ]
Use command_id instead of req->tag in trace_nvme_complete_rq(), because of commit e7006de6c238 ("nvme: code command_id with a genctr for use authentication after release"), cmd->common.command_id is set to ((genctl & 0xf)< 12 | req->tag), no longer req->tag, which makes cid in trace_nvme_complete_rq and trace_nvme_setup_cmd are not the same.
--- drivers/nvme/host/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/trace.h +1 -1
@@ -98,7 +98,7 @@ TRACE_EVENT(nvme_complete_rq,TP_fast_assign ( __entry->ctrl_id = nvme_req(req)->ctrl->instance; __entry->qid =nvme_req_qid (req); - __entry->cid = req->tag; + __entry->cid =nvme_req (req)->cmd->common.command_id; __entry->result =le64_to_cpu (nvme_req (req)->result.u64); __entry->retries =nvme_req (req)->retries; __entry->flags =nvme_req (req)->flags;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 359/545 jbd2: fix outstanding credits assert in jbd2_journal_commit_transaction()
In reply to Greg Kroah-HartmanFrom: Zhang Yi <[email protected]>
[ Upstream commit a89573ce4ad32f19f43ec669771726817e185be0 ]
We catch an assert problem in jbd2_journal_commit_transaction() when doing fsstress and request falut injection tests. The problem is happened in a race condition between jbd2_journal_commit_transaction() and ext4_end_io_end(). Firstly, ext4_writepages() writeback dirty pages and start reserved handle, and then the journal was aborted due to some previous metadata IO error, jbd2_journal_abort() start to commit current running transaction, the committing procedure could be raced by ext4_end_io_end() and lead to subtract j_reserved_credits twice from commit_transaction->t_outstanding_credits, finally the t_outstanding_credits is mistakenly smaller than t_nr_buffers and trigger assert.
kjournald2 kworker
jbd2_journal_commit_transaction()
write_unlock(&journal->j_state_lock); atomic_sub(j_reserved_credits, t_outstanding_credits); //sub once
jbd2_journal_start_reserved()
start_this_handle() //detect aborted journal
jbd2_journal_free_reserved() //get running transaction
read_lock(&journal->j_state_lock)
__jbd2_journal_unreserve_handle()
atomic_sub(j_reserved_credits, t_outstanding_credits);
//sub again
read_unlock(&journal->j_state_lock); journal->j_running_transaction = NULL; J_ASSERT(t_nr_buffers <= t_outstanding_credits) //bomb!!!
Fix this issue by using journal->j_state_lock to protect the subtraction in jbd2_journal_commit_transaction().
--- fs/jbd2/commit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jbd2/commit.c +1 -1
@@ -564,13 +564,13 @@ void jbd2_journal_commit_transaction(journal_t *journal)*/ jbd2_journal_switch_revoke_table (journal); +write_lock (&journal->j_state_lock);/* * Reserved credits cannot be claimed anymore, free them */ atomic_sub (atomic_read (&journal->j_reserved_credits), &commit_transaction->t_outstanding_credits); -write_lock (&journal->j_state_lock);trace_jbd2_commit_flushing (journal, commit_transaction); stats.run.rs_flushing = jiffies; stats.run.rs_locked = jbd2_time_diff(stats.run.rs_locked,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 360/545 ext4: recover csum seed of tmp_inode after migrating to extents
In reply to Greg Kroah-HartmanFrom: Li Lingfeng <[email protected]>
[ Upstream commit 07ea7a617d6b278fb7acedb5cbe1a81ce2de7d0c ]
When migrating to extents, the checksum seed of temporary inode need to be replaced by inode's, otherwise the inode checksums will be incorrect when swapping the inodes data.
However, the temporary inode can not match it's checksum to itself since it has lost it's own checksum seed.
mkfs.ext4 -F /dev/sdc
mount /dev/sdc /mnt/sdcxfs_io -fc "pwrite 4k 4k" -c "fsync" /mnt/sdc/testfile chattr -e /mnt/sdc/testfile
chattr +e /mnt/sdc/testfile
umount /dev/sdc
fsck -fn /dev/sdc
========
...
Pass 1: Checking inodes, blocks, and sizes
Inode 13 passes checks, but checksum does not match inode. Fix? no
...
========
The fix is simple, save the checksum seed of temporary inode, and recover it after migrating to extents.
--- fs/ext4/migrate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/migrate.c +3 -1
@@ -417,7 +417,7 @@ int ext4_ext_migrate(struct inode *inode)struct inode *tmp_inode =NULL ;struct migrate_struct lb;unsigned long max_entries; -__u32 goal; +__u32 goal, tmp_csum_seed;uid_t owner[2 ];/*
@@ -465,6 +465,7 @@ int ext4_ext_migrate(struct inode *inode)* the migration. */ ei =EXT4_I (inode); + tmp_csum_seed =EXT4_I (tmp_inode)->i_csum_seed;EXT4_I (tmp_inode)->i_csum_seed = ei->i_csum_seed;i_size_write (tmp_inode,i_size_read (inode));/*
@@ -575,6 +576,7 @@ int ext4_ext_migrate(struct inode *inode)* the inode is not visible to user space. */ tmp_inode->i_blocks =0 ; +EXT4_I (tmp_inode)->i_csum_seed = tmp_csum_seed;/* Reset the extent details */ ext4_ext_tree_init (handle, tmp_inode);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 361/545 jbd2: fix assertion jh->b_frozen_data == NULL failure when journal aborted
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
[ Upstream commit 4a734f0869f970b8a9b65062ea40b09a5da9dba8 ]
Following process will fail assertion 'jh->b_frozen_data == NULL' in jbd2_journal_dirty_metadata():
jbd2_journal_commit_transaction
unlink(dir/a)
jh->b_transaction = trans1
jh->b_jlist = BJ_Metadata
journal->j_running_transaction = NULL
trans1->t_state = T_COMMITunlink(dir/b)
handle->h_trans = trans2
do_get_write_access
jh->b_modified = 0
jh->b_frozen_data = frozen_buffer
jh->b_next_transaction = trans2
jbd2_journal_dirty_metadata
is_handle_aborted
is_journal_aborted // return false
--> jbd2 abort <--
while (commit_transaction->t_buffers)
if (is_journal_aborted)
jbd2_journal_refile_buffer
__jbd2_journal_refile_buffer
WRITE_ONCE(jh->b_transaction,
jh->b_next_transaction)
WRITE_ONCE(jh->b_next_transaction, NULL)
__jbd2_journal_file_buffer(jh, BJ_Reserved)
J_ASSERT_JH(jh, jh->b_frozen_data == NULL) // assertion failure !The reproducer (See detail in [Link]) reports:
------------[ cut here ]------------ kernel BUG at fs/jbd2/transaction.c:1629! invalid opcode: 0000 [#1] PREEMPT SMP CPU: 2 PID: 584 Comm: unlink Tainted: G W 5.19.0-rc6-00115-g4a57a8400075-dirty #697 RIP: 0010:jbd2_journal_dirty_metadata+0x3c5/0x470 RSP: 0018:ffffc90000be7ce0 EFLAGS: 00010202 Call Trace: <TASK> __ext4_handle_dirty_metadata+0xa0/0x290 ext4_handle_dirty_dirblock+0x10c/0x1d0 ext4_delete_entry+0x104/0x200 __ext4_unlink+0x22b/0x360 ext4_unlink+0x275/0x390 vfs_unlink+0x20b/0x4c0 do_unlinkat+0x42f/0x4c0 __x64_sys_unlink+0x37/0x50 do_syscall_64+0x35/0x80
After journal aborting, __jbd2_journal_refile_buffer() is executed with holding @jh->b_state_lock, we can fix it by moving 'is_handle_aborted()' into the area protected by @jh->b_state_lock.
--- fs/jbd2/transaction.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
fs/jbd2/transaction.c +12 -2
@@ -1460,8 +1460,6 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)struct journal_head *jh;int ret =0 ; -if (is_handle_aborted (handle)) -return -EROFS ;if (!buffer_jbd (bh))return -EUCLEAN ;
@@ -1508,6 +1506,18 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) journal = transaction->t_journal;spin_lock (&jh->b_state_lock); +if (is_handle_aborted (handle)) { +/* +* Check journal aborting with @jh->b_state_lock locked, +* since 'jh->b_transaction' could be replaced with +* 'jh->b_next_transaction' during old transaction +* committing if journal aborted, which may fail +* assertion on 'jh->b_frozen_data == NULL'. +*/ + ret = -EROFS ; + goto out_unlock_bh; + } +if (jh->b_modified ==0 ) {/* * This buffer's got modified and becoming part
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 362/545 usb: cdns3: Dont use priv_dev uninitialized in cdns3_gadget_ep_enable()
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 78acd4ca433425e6dd4032cfc2156c60e34931f2 ]
Clang warns:
drivers/usb/cdns3/cdns3-gadget.c:2290:11: error: variable 'priv_dev' is uninitialized when used here [-Werror,-Wuninitialized]
dev_dbg(priv_dev->dev, "usbss: invalid parameters\n");
^~~~~~~~
include/linux/dev_printk.h:155:18: note: expanded from macro 'dev_dbg'
dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
^~~
include/linux/dynamic_debug.h:167:7: note: expanded from macro 'dynamic_dev_dbg'
dev, fmt, ##__VA_ARGS__)
^~~
include/linux/dynamic_debug.h:152:56: note: expanded from macro '_dynamic_func_call'
__dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
^~~~~~~~~~~
include/linux/dynamic_debug.h:134:15: note: expanded from macro '__dynamic_func_call'
func(&id, ##__VA_ARGS__); \
^~~~~~~~~~~
drivers/usb/cdns3/cdns3-gadget.c:2278:31: note: initialize the variable 'priv_dev' to silence this warning
struct cdns3_device *priv_dev;
^
= NULL1 error generated.
The priv_dev assignment was moved below the if statement to avoid potentially dereferencing ep before it was checked but priv_dev is used in the dev_dbg() call.
To fix this, move the priv_dev and comp_desc assignments back to their original spot and hoist the ep check above those assignments with a call to pr_debug() instead of dev_dbg().
--- drivers/usb/cdns3/gadget.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/usb/cdns3/gadget.c +8 -4
@@ -2293,16 +2293,20 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep,int ret =0 ;int val; +if (!ep) { +pr_debug ("usbss: ep not configured?\n" ); +return -EINVAL ; + } + priv_ep =ep_to_cdns3_ep (ep); + priv_dev = priv_ep->cdns3_dev; + comp_desc = priv_ep->endpoint.comp_desc; -if (!ep || !desc || desc->bDescriptorType !=USB_DT_ENDPOINT ) { +if (!desc || desc->bDescriptorType !=USB_DT_ENDPOINT ) {dev_dbg (priv_dev->dev,"usbss: invalid parameters\n" );return -EINVAL ; } - comp_desc = priv_ep->endpoint.comp_desc; - priv_dev = priv_ep->cdns3_dev; -if (!desc->wMaxPacketSize) {dev_err (priv_dev->dev,"usbss: missing wMaxPacketSize\n" );return -EINVAL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 363/545 opp: Fix error check in dev_pm_opp_attach_genpd()
In reply to Greg Kroah-HartmanFrom: Tang Bin <[email protected]>
[ Upstream commit 4ea9496cbc959eb5c78f3e379199aca9ef4e386b ]
dev_pm_domain_attach_by_name() may return NULL in some cases, so IS_ERR() doesn't meet the requirements. Thus fix it.
--- drivers/opp/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/opp/core.c +2 -2
@@ -2052,8 +2052,8 @@ struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, } virt_dev =dev_pm_domain_attach_by_name (dev, *name); -if (IS_ERR (virt_dev)) { - ret =PTR_ERR (virt_dev); +if (IS_ERR_OR_NULL (virt_dev)) { + ret =PTR_ERR (virt_dev) ? : -ENODEV ;dev_err (dev,"Couldn't attach to pm_domain: %d\n" , ret); goto err; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 364/545 ASoC: cros_ec_codec: Fix refcount leak in cros_ec_codec_platform_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 0a034d93ee929a9ea89f3fa5f1d8492435b9ee6e ]
of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak.
--- sound/soc/codecs/cros_ec_codec.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/codecs/cros_ec_codec.c +1 -0
@@ -994,6 +994,7 @@ static int cros_ec_codec_platform_probe(struct platform_device *pdev)dev_dbg (dev,"ap_shm_phys_addr=%#llx len=%#x\n" , priv->ap_shm_phys_addr, priv->ap_shm_len); } +of_node_put (node); }#endif
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 365/545 ASoC: samsung: Fix error handling in aries_audio_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 3e2649c5e8643bea0867bb1dd970fedadb0eb7f3 ]
of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. This function is missing of_node_put(cpu) in the error path. Fix this by goto out label. of_node_put() will check NULL pointer.
--- sound/soc/samsung/aries_wm8994.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/samsung/aries_wm8994.c +4 -2
@@ -628,8 +628,10 @@ static int aries_audio_probe(struct platform_device *pdev)return -EINVAL ; codec =of_get_child_by_name (dev->of_node,"codec" ); -if (!codec) -return -EINVAL ; +if (!codec) { + ret = -EINVAL ; + goto out; + }for_each_card_prelinks (card, i, dai_link) { dai_link->codecs->of_node = of_parse_phandle(codec,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 366/545 ASoC: mediatek: mt8173: Fix refcount leak in mt8173_rt5650_rt5676_dev_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit ae4f11c1ed2d67192fdf3d89db719ee439827c11 ]
of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Fix missing of_node_put() in error paths.
--- sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c +7 -3
@@ -256,14 +256,16 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)if (!mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S ].codecs[0 ].of_node) {dev_err (&pdev->dev,"Property 'audio-codec' missing or invalid\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto put_node; } mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S ].codecs[1 ].of_node =of_parse_phandle (pdev->dev.of_node,"mediatek,audio-codec" ,1 );if (!mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S ].codecs[1 ].of_node) {dev_err (&pdev->dev,"Property 'audio-codec' missing or invalid\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto put_node; } mt8173_rt5650_rt5676_codec_conf[0 ].dlc.of_node = mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S ].codecs[1 ].of_node;
@@ -276,7 +278,8 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)if (!mt8173_rt5650_rt5676_dais[DAI_LINK_HDMI_I2S ].codecs->of_node) {dev_err (&pdev->dev,"Property 'audio-codec' missing or invalid\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto put_node; } card->dev = &pdev->dev;
@@ -286,6 +289,7 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)dev_err (&pdev->dev,"%s snd_soc_register_card fail %d\n" , __func__, ret); +put_node:of_node_put (platform_node);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 367/545 ASoC: mt6797-mt6351: Fix refcount leak in mt6797_mt6351_dev_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 7472eb8d7dd12b6b9b1a4f4527719cc9c7f5965f ]
of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak.
--- sound/soc/mediatek/mt6797/mt6797-mt6351.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/soc/mediatek/mt6797/mt6797-mt6351.c +5 -1
@@ -217,7 +217,8 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev)if (!codec_node) {dev_err (&pdev->dev,"Property 'audio-codec' missing or invalid\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto put_platform_node; }for_each_card_prelinks (card, i, dai_link) {if (dai_link->codecs->name)
@@ -230,6 +231,9 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev)dev_err (&pdev->dev,"%s snd_soc_register_card fail %d\n" , __func__, ret); +of_node_put (codec_node); +put_platform_node: +of_node_put (platform_node);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 368/545 ASoC: codecs: da7210: add check for i2c_add_driver
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 82fa8f581a954ddeec1602bed9f8b4a09d100e6e ]
As i2c_add_driver could return error if fails, it should be better to check the return value.
However, if the CONFIG_I2C and CONFIG_SPI_MASTER are both true, the return value of i2c_add_driver will be covered by spi_register_driver.
Therefore, it is necessary to add check and return error if fails.
--- sound/soc/codecs/da7210.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/codecs/da7210.c +2 -0
@@ -1336,6 +1336,8 @@ static int __init da7210_modinit(void)int ret =0 ;#if IS_ENABLED (CONFIG_I2C ) ret =i2c_add_driver (&da7210_i2c_driver); +if (ret) +return ret;#endif #if defined(CONFIG_SPI_MASTER ) ret =spi_register_driver (&da7210_spi_driver);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 369/545 ASoC: mediatek: mt8173-rt5650: Fix refcount leak in mt8173_rt5650_dev_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit efe2178d1a32492f99e7f1f2568eea5c88a85729 ]
of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Fix refcount leak in some error paths.
--- sound/soc/mediatek/mt8173/mt8173-rt5650.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/soc/mediatek/mt8173/mt8173-rt5650.c +6 -3
@@ -280,7 +280,8 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)if (!mt8173_rt5650_dais[DAI_LINK_CODEC_I2S ].codecs[0 ].of_node) {dev_err (&pdev->dev,"Property 'audio-codec' missing or invalid\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto put_platform_node; } mt8173_rt5650_dais[DAI_LINK_CODEC_I2S ].codecs[1 ].of_node = mt8173_rt5650_dais[DAI_LINK_CODEC_I2S ].codecs[0 ].of_node;
@@ -293,7 +294,7 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)dev_err (&pdev->dev,"%s codec_capture_dai name fail %d\n" , __func__, ret); -return ret; + goto put_platform_node; } mt8173_rt5650_dais[DAI_LINK_CODEC_I2S ].codecs[1 ].dai_name = codec_capture_dai;
@@ -315,7 +316,8 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)if (!mt8173_rt5650_dais[DAI_LINK_HDMI_I2S ].codecs->of_node) {dev_err (&pdev->dev,"Property 'audio-codec' missing or invalid\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto put_platform_node; } card->dev = &pdev->dev;
@@ -324,6 +326,7 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)dev_err (&pdev->dev,"%s snd_soc_register_card fail %d\n" , __func__, ret); +put_platform_node:of_node_put (platform_node);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 370/545 serial: 8250: Export ICR access helpers for internal use
In reply to Greg Kroah-HartmanFrom: Maciej W. Rozycki <[email protected]>
[ Upstream commit cb5a40e3143bc64437858b337273fd63cc42e9c2 ]
Make ICR access helpers available outside 8250_port.c, however retain them as ordinary static functions so as not to regress code generation.
This is because serial_icr_write' is currently automatically inlined by GCC, however serial_icr_read' is not. Making them both static inline would grow code produced, e.g.:
$ i386-linux-gnu-size --format=gnu 8250_port-{old,new}.o
text data bss total filename
15065 3378 0 18443 8250_port-old.o
15289 3378 0 18667 8250_port-new.oand:
$ riscv64-linux-gnu-size --format=gnu 8250_port-{old,new}.o
text data bss total filename
16980 5306 0 22286 8250_port-old.o
17124 5306 0 22430 8250_port-new.owhile making them external would needlessly add a new module interface and lose the benefit from `serial_icr_write' getting inlined outside 8250_port.o.
--- drivers/tty/serial/8250/8250.h | 22 ++++++++++++++++++++++ drivers/tty/serial/8250/8250_port.c | 21 --------------------- 2 files changed, 22 insertions(+), 21 deletions(-)
drivers/tty/serial/8250/8250.h +22 -0
@@ -119,6 +119,28 @@ static inline void serial_out(struct uart_8250_port *up, int offset, int value) up->port.serial_out (&up->port, offset, value); } +/* +* For the 16C950 +*/ +static void serial_icr_write (struct uart_8250_port *up,int offset,int value) +{ +serial_out (up,UART_SCR , offset); +serial_out (up,UART_ICR , value); +} + +static unsigned int __maybe_unused serial_icr_read (struct uart_8250_port *up, +int offset) +{ +unsigned int value; + +serial_icr_write (up,UART_ACR , up->acr |UART_ACR_ICRRD ); +serial_out (up,UART_SCR , offset); + value =serial_in (up,UART_ICR ); +serial_icr_write (up,UART_ACR , up->acr); + +return value; +} +void serial8250_clear_and_reinit_fifos (struct uart_8250_port *p);static inline int serial_dl_read (struct uart_8250_port *up)
drivers/tty/serial/8250/8250_port.c +0 -21
@@ -529,27 +529,6 @@ serial_port_out_sync(struct uart_port *p, int offset, int value) } } -/* -* For the 16C950 -*/ -static void serial_icr_write (struct uart_8250_port *up,int offset,int value) -{ -serial_out (up,UART_SCR , offset); -serial_out (up,UART_ICR , value); -} - -static unsigned int serial_icr_read (struct uart_8250_port *up,int offset) -{ -unsigned int value; - -serial_icr_write (up,UART_ACR , up->acr |UART_ACR_ICRRD ); -serial_out (up,UART_SCR , offset); - value =serial_in (up,UART_ICR ); -serial_icr_write (up,UART_ACR , up->acr); - -return value; -} -/* * FIFO support. */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 371/545 serial: 8250_dw: Store LSR into lsr_saved_flags in dw8250_tx_wait_empty()
In reply to Greg Kroah-HartmanFrom: Ilpo Järvinen <[email protected]>
[ Upstream commit af14f3007e2dca0d112f10f6717ba43093f74e81 ]
Make sure LSR flags are preserved in dw8250_tx_wait_empty(). This function is called from a low-level out function and therefore cannot call serial_lsr_in() as it would lead to infinite recursion.
It is borderline if the flags need to be saved here at all since this code relates to writing LCR register which usually implies no important characters should be arriving.
--- drivers/tty/serial/8250/8250_dw.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/tty/serial/8250/8250_dw.c +3 -0
@@ -124,12 +124,15 @@ static void dw8250_check_lcr(struct uart_port *p, int value)/* Returns once the transmitter is empty or we run out of retries */ static void dw8250_tx_wait_empty (struct uart_port *p) { +struct uart_8250_port *up =up_to_u8250p (p);unsigned int tries =20000 ;unsigned int delay_threshold = tries -1000 ;unsigned int lsr;while (tries--) { lsr =readb (p->membase + (UART_LSR << p->regshift)); + up->lsr_saved_flags |= lsr &LSR_SAVE_FLAGS ; +if (lsr &UART_LSR_TEMT )break ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 372/545 ASoC: codecs: msm8916-wcd-digital: move gains from SX_TLV to S8_TLV
In reply to Greg Kroah-HartmanFrom: Srinivas Kandagatla <[email protected]>
[ Upstream commit 5babb012c847beb6c8c7108fd78f650b7a2c6054 ]
move all the digital gains form using SX_TLV to S8_TLV, these gains are actually 8 bit gains with 7th signed bit and ranges from -84dB to +40dB
rest of the Qualcomm wcd codecs uses these properly.
--- sound/soc/codecs/msm8916-wcd-digital.c | 46 +++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-)
sound/soc/codecs/msm8916-wcd-digital.c +23 -23
@@ -328,8 +328,8 @@ static const struct snd_kcontrol_new rx1_mix2_inp1_mux = SOC_DAPM_ENUM(static const struct snd_kcontrol_new rx2_mix2_inp1_mux =SOC_DAPM_ENUM ("RX2 MIX2 INP1 Mux" , rx2_mix2_inp1_chain_enum); -/* Digital Gain control -38.4 dB to +38.4 dB in 0.3 dB steps */ -static const DECLARE_TLV_DB_SCALE(digital_gain, -3840, 30, 0); +/* Digital Gain control -84 dB to +40 dB in 1 dB steps */ +static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);/* Cutoff Freq for High Pass Filter at -3dB */ static const char *const hpf_cutoff_text[] = {
@@ -510,15 +510,15 @@ static int wcd_iir_filter_info(struct snd_kcontrol *kcontrol,static const struct snd_kcontrol_new msm8916_wcd_digital_snd_controls[] = {SOC_SINGLE_S8_TLV ("RX1 Digital Volume" ,LPASS_CDC_RX1_VOL_CTL_B2_CTL , --128 ,127 , digital_gain), +-84 ,40 , digital_gain),SOC_SINGLE_S8_TLV ("RX2 Digital Volume" ,LPASS_CDC_RX2_VOL_CTL_B2_CTL , --128 ,127 , digital_gain), +-84 ,40 , digital_gain),SOC_SINGLE_S8_TLV ("RX3 Digital Volume" ,LPASS_CDC_RX3_VOL_CTL_B2_CTL , --128 ,127 , digital_gain), +-84 ,40 , digital_gain),SOC_SINGLE_S8_TLV ("TX1 Digital Volume" ,LPASS_CDC_TX1_VOL_CTL_GAIN , --128 ,127 , digital_gain), +-84 ,40 , digital_gain),SOC_SINGLE_S8_TLV ("TX2 Digital Volume" ,LPASS_CDC_TX2_VOL_CTL_GAIN , --128 ,127 , digital_gain), +-84 ,40 , digital_gain),SOC_ENUM ("TX1 HPF Cutoff" , tx1_hpf_cutoff_enum),SOC_ENUM ("TX2 HPF Cutoff" , tx2_hpf_cutoff_enum),SOC_SINGLE ("TX1 HPF Switch" ,LPASS_CDC_TX1_MUX_CTL ,3 ,1 ,0 ),
@@ -553,22 +553,22 @@ static const struct snd_kcontrol_new msm8916_wcd_digital_snd_controls[] = {WCD_IIR_FILTER_CTL ("IIR2 Band3" ,IIR2 ,BAND3 ),WCD_IIR_FILTER_CTL ("IIR2 Band4" ,IIR2 ,BAND4 ),WCD_IIR_FILTER_CTL ("IIR2 Band5" ,IIR2 ,BAND5 ), -SOC_SINGLE_SX_TLV ("IIR1 INP1 Volume" ,LPASS_CDC_IIR1_GAIN_B1_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("IIR1 INP2 Volume" ,LPASS_CDC_IIR1_GAIN_B2_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("IIR1 INP3 Volume" ,LPASS_CDC_IIR1_GAIN_B3_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("IIR1 INP4 Volume" ,LPASS_CDC_IIR1_GAIN_B4_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("IIR2 INP1 Volume" ,LPASS_CDC_IIR2_GAIN_B1_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("IIR2 INP2 Volume" ,LPASS_CDC_IIR2_GAIN_B2_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("IIR2 INP3 Volume" ,LPASS_CDC_IIR2_GAIN_B3_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("IIR2 INP4 Volume" ,LPASS_CDC_IIR2_GAIN_B4_CTL , - 0, -84, 40, digital_gain), +SOC_SINGLE_S8_TLV ("IIR1 INP1 Volume" ,LPASS_CDC_IIR1_GAIN_B1_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("IIR1 INP2 Volume" ,LPASS_CDC_IIR1_GAIN_B2_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("IIR1 INP3 Volume" ,LPASS_CDC_IIR1_GAIN_B3_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("IIR1 INP4 Volume" ,LPASS_CDC_IIR1_GAIN_B4_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("IIR2 INP1 Volume" ,LPASS_CDC_IIR2_GAIN_B1_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("IIR2 INP2 Volume" ,LPASS_CDC_IIR2_GAIN_B2_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("IIR2 INP3 Volume" ,LPASS_CDC_IIR2_GAIN_B3_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("IIR2 INP4 Volume" ,LPASS_CDC_IIR2_GAIN_B4_CTL , + -84, 40, digital_gain), };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 373/545 ASoC: codecs: wcd9335: move gains from SX_TLV to S8_TLV
In reply to Greg Kroah-HartmanFrom: Srinivas Kandagatla <[email protected]>
[ Upstream commit 2fbe0953732e06b471cdedbf6f615b84235580d8 ]
move all the digital gains form using SX_TLV to S8_TLV, these gains are actually 8 bit gains with 7th signed bit and ranges from -84dB to +40dB
rest of the Qualcomm wcd codecs uses these properly.
--- sound/soc/codecs/wcd9335.c | 81 +++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 45 deletions(-)
sound/soc/codecs/wcd9335.c +36 -45
@@ -2252,51 +2252,42 @@ static int wcd9335_rx_hph_mode_put(struct snd_kcontrol *kc,static const struct snd_kcontrol_new wcd9335_snd_controls[] = {/* -84dB min - 40dB max */ -SOC_SINGLE_SX_TLV ("RX0 Digital Volume" ,WCD9335_CDC_RX0_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX1 Digital Volume" ,WCD9335_CDC_RX1_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX2 Digital Volume" ,WCD9335_CDC_RX2_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX3 Digital Volume" ,WCD9335_CDC_RX3_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX4 Digital Volume" ,WCD9335_CDC_RX4_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX5 Digital Volume" ,WCD9335_CDC_RX5_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX6 Digital Volume" ,WCD9335_CDC_RX6_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX7 Digital Volume" ,WCD9335_CDC_RX7_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX8 Digital Volume" ,WCD9335_CDC_RX8_RX_VOL_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX0 Mix Digital Volume" , -WCD9335_CDC_RX0_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX1 Mix Digital Volume" , -WCD9335_CDC_RX1_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX2 Mix Digital Volume" , -WCD9335_CDC_RX2_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX3 Mix Digital Volume" , -WCD9335_CDC_RX3_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX4 Mix Digital Volume" , -WCD9335_CDC_RX4_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX5 Mix Digital Volume" , -WCD9335_CDC_RX5_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX6 Mix Digital Volume" , -WCD9335_CDC_RX6_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX7 Mix Digital Volume" , -WCD9335_CDC_RX7_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), -SOC_SINGLE_SX_TLV ("RX8 Mix Digital Volume" , -WCD9335_CDC_RX8_RX_VOL_MIX_CTL , -0 ,-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX0 Digital Volume" ,WCD9335_CDC_RX0_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX1 Digital Volume" ,WCD9335_CDC_RX1_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX2 Digital Volume" ,WCD9335_CDC_RX2_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX3 Digital Volume" ,WCD9335_CDC_RX3_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX4 Digital Volume" ,WCD9335_CDC_RX4_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX5 Digital Volume" ,WCD9335_CDC_RX5_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX6 Digital Volume" ,WCD9335_CDC_RX6_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX7 Digital Volume" ,WCD9335_CDC_RX7_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX8 Digital Volume" ,WCD9335_CDC_RX8_RX_VOL_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX0 Mix Digital Volume" ,WCD9335_CDC_RX0_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX1 Mix Digital Volume" ,WCD9335_CDC_RX1_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX2 Mix Digital Volume" ,WCD9335_CDC_RX2_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX3 Mix Digital Volume" ,WCD9335_CDC_RX3_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX4 Mix Digital Volume" ,WCD9335_CDC_RX4_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX5 Mix Digital Volume" ,WCD9335_CDC_RX5_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX6 Mix Digital Volume" ,WCD9335_CDC_RX6_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX7 Mix Digital Volume" ,WCD9335_CDC_RX7_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain), +SOC_SINGLE_S8_TLV ("RX8 Mix Digital Volume" ,WCD9335_CDC_RX8_RX_VOL_MIX_CTL , +-84 ,40 , digital_gain),SOC_ENUM ("RX INT0_1 HPF cut off" , cf_int0_1_enum),SOC_ENUM ("RX INT0_2 HPF cut off" , cf_int0_2_enum),SOC_ENUM ("RX INT1_1 HPF cut off" , cf_int1_1_enum),
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 374/545 rpmsg: mtk_rpmsg: Fix circular locking dependency
In reply to Greg Kroah-HartmanFrom: AngeloGioacchino Del Regno <[email protected]>
[ Upstream commit 353d9214682e65c55cdffad8c82139a3321c5f13 ]
During execution of the worker that's used to register rpmsg devices we are safely locking the channels mutex but, when creating a new endpoint for such devices, we are registering a IPI on the SCP, which then makes the SCP to trigger an interrupt, lock its own mutex and in turn register more subdevices.
This creates a circular locking dependency situation, as the mtk_rpmsg channels_lock will then depend on the SCP IPI lock.
[ 15.447736] ======================================================
[ 15.460158] WARNING: possible circular locking dependency detected
[ 15.460161] 5.17.0-next-20220324+ #399 Not tainted
[ 15.460165] ------------------------------------------------------
[ 15.460166] kworker/0:3/155 is trying to acquire lock:
[ 15.460170] ffff5b4d0eaf1308 (&scp->ipi_desc[i].lock){+.+.}-{4:4}, at: scp_ipi_lock+0x34/0x50 [mtk_scp_ipi]
[ 15.504958]
[] but task is already holding lock:
[ 15.504960] ffff5b4d0e8f1918 (&mtk_subdev->channels_lock){+.+.}-{4:4}, at: mtk_register_device_work_function+0x50/0x1cc [mtk_rpmsg]
[ 15.504978][] which lock already depends on the new lock.
[ 15.504980]
[] the existing dependency chain (in reverse order) is:
[ 15.504982]
[] -> #1 (&mtk_subdev->channels_lock){+.+.}-{4:4}:
[ 15.504990] lock_acquire+0x68/0x84
[ 15.504999] __mutex_lock+0xa4/0x3e0
[ 15.505007] mutex_lock_nested+0x40/0x70
[ 15.505012] mtk_rpmsg_ns_cb+0xe4/0x134 [mtk_rpmsg]
[ 15.641684] mtk_rpmsg_ipi_handler+0x38/0x64 [mtk_rpmsg]
[ 15.641693] scp_ipi_handler+0xbc/0x180 [mtk_scp]
[ 15.663905] mt8192_scp_irq_handler+0x44/0xa4 [mtk_scp]
[ 15.663915] scp_irq_handler+0x6c/0xa0 [mtk_scp]
[ 15.685779] irq_thread_fn+0x34/0xa0
[ 15.685785] irq_thread+0x18c/0x240
[ 15.685789] kthread+0x104/0x110
[ 15.709579] ret_from_fork+0x10/0x20
[ 15.709586]
[] -> #0 (&scp->ipi_desc[i].lock){+.+.}-{4:4}:
[ 15.731271] __lock_acquire+0x11e4/0x1910
[ 15.740367] lock_acquire.part.0+0xd8/0x220
[ 15.749813] lock_acquire+0x68/0x84
[ 15.757861] __mutex_lock+0xa4/0x3e0
[ 15.766084] mutex_lock_nested+0x40/0x70
[ 15.775006] scp_ipi_lock+0x34/0x50 [mtk_scp_ipi]
[ 15.785503] scp_ipi_register+0x40/0xa4 [mtk_scp_ipi]
[ 15.796697] scp_register_ipi+0x1c/0x30 [mtk_scp]
[ 15.807194] mtk_rpmsg_create_ept+0xa0/0x108 [mtk_rpmsg]
[ 15.818912] rpmsg_create_ept+0x44/0x60
[ 15.827660] cros_ec_rpmsg_probe+0x15c/0x1f0
[ 15.837282] rpmsg_dev_probe+0x128/0x1d0
[ 15.846203] really_probe.part.0+0xa4/0x2a0
[ 15.855649] __driver_probe_device+0xa0/0x150
[ 15.865443] driver_probe_device+0x48/0x150
[ 15.877157] __device_attach_driver+0xc0/0x12c
[ 15.889359] bus_for_each_drv+0x80/0xe0
[ 15.900330] __device_attach+0xe4/0x190
[ 15.911303] device_initial_probe+0x1c/0x2c
[ 15.922969] bus_probe_device+0xa8/0xb0
[ 15.933927] device_add+0x3a8/0x8a0
[ 15.944193] device_register+0x28/0x40
[ 15.954970] rpmsg_register_device+0x5c/0xa0
[ 15.966782] mtk_register_device_work_function+0x148/0x1cc [mtk_rpmsg]
[ 15.983146] process_one_work+0x294/0x664
[ 15.994458] worker_thread+0x7c/0x45c
[ 16.005069] kthread+0x104/0x110
[ 16.014789] ret_from_fork+0x10/0x20
[ 16.025201][] other info that might help us debug this:
[ 16.047769] Possible unsafe locking scenario:
[ 16.063942] CPU0 CPU1 [ 16.075166] ---- ---- [ 16.086376] lock(&mtk_subdev->channels_lock); [ 16.097592] lock(&scp->ipi_desc[i].lock); [ 16.113188] lock(&mtk_subdev->channels_lock); [ 16.129482] lock(&scp->ipi_desc[i].lock); [ 16.140020]
[] *** DEADLOCK ***
[ 16.158282] 4 locks held by kworker/0:3/155:
[ 16.168978] #0: ffff5b4d00008748 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work+0x1fc/0x664
[ 16.190017] #1: ffff80000953bdc8 ((work_completion)(&mtk_subdev->register_work)){+.+.}-{0:0}, at: process_one_work+0x1fc/0x664
[ 16.215269] #2: ffff5b4d0e8f1918 (&mtk_subdev->channels_lock){+.+.}-{4:4}, at: mtk_register_device_work_function+0x50/0x1cc [mtk_rpmsg]
[ 16.242131] #3: ffff5b4d05964190 (&dev->mutex){....}-{4:4}, at: __device_attach+0x44/0x190To solve this, simply unlock the channels_lock mutex before calling mtk_rpmsg_register_device() and relock it right after, as safety is still ensured by the locking mechanism that happens right after through SCP.
--- drivers/rpmsg/mtk_rpmsg.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/rpmsg/mtk_rpmsg.c +2 -0
@@ -234,7 +234,9 @@ static void mtk_register_device_work_function(struct work_struct *register_work)if (info->registered)continue ; +mutex_unlock (&subdev->channels_lock); ret =mtk_rpmsg_register_device (subdev, &info->info); +mutex_lock (&subdev->channels_lock);if (ret) {dev_err (&pdev->dev,"Can't create rpmsg_device\n" );continue ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 375/545 remoteproc: k3-r5: Fix refcount leak in k3_r5_cluster_of_init
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit fa220c05d282e7479abe08b54e3bdffd06c25e97 ]
Every iteration of for_each_available_child_of_node() decrements the reference count of the previous node.
When breaking early from a for_each_available_child_of_node() loop, we need to explicitly call of_node_put() on the child node. Add missing of_node_put() to avoid refcount leak.
--- drivers/remoteproc/ti_k3_r5_remoteproc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/remoteproc/ti_k3_r5_remoteproc.c +2 -0
@@ -1283,6 +1283,7 @@ static int k3_r5_cluster_of_init(struct platform_device *pdev)if (!cpdev) { ret = -ENODEV ;dev_err (dev,"could not get R5 core platform device\n" ); +of_node_put (child); goto fail; }
@@ -1291,6 +1292,7 @@ static int k3_r5_cluster_of_init(struct platform_device *pdev)dev_err (dev,"k3_r5_core_of_init failed, ret = %d\n" , ret);put_device (&cpdev->dev); +of_node_put (child); goto fail; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 376/545 selftests/livepatch: better synchronize test_klp_callbacks_busy
In reply to Greg Kroah-HartmanFrom: Joe Lawrence <[email protected]>
[ Upstream commit 55eb9a6c8bf3e2099863118ef53e02d9f44f85a8 ]
The test_klp_callbacks_busy module conditionally blocks a future livepatch transition by busy waiting inside its workqueue function, busymod_work_func(). After scheduling this work, a test livepatch is loaded, introducing the transition under test.
Both events are marked in the kernel log for later verification, but there is no synchronization to ensure that busymod_work_func() logs its function entry message before subsequent selftest commands log their own messages. This can lead to a rare test failure due to unexpected ordering like:
# --- expected # +++ result # @@ -1,7 +1,7 @@
# % modprobe test_klp_callbacks_busy block_transition=Y
# test_klp_callbacks_busy: test_klp_callbacks_busy_init
# -test_klp_callbacks_busy: busymod_work_func enter
# % modprobe test_klp_callbacks_demo
# +test_klp_callbacks_busy: busymod_work_func enter
# livepatch: enabling patch 'test_klp_callbacks_demo' # livepatch: 'test_klp_callbacks_demo': initializing patching transition # test_klp_callbacks_demo: pre_patch_callback: vmlinux
Force the module init function to wait until busymod_work_func() has started (and logged its message), before exiting to the next selftest steps.
--- lib/livepatch/test_klp_callbacks_busy.c | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/livepatch/test_klp_callbacks_busy.c +8 -0
@@ -16,10 +16,12 @@ MODULE_PARM_DESC(block_transition, "blocstatic void busymod_work_func (struct work_struct *work); static DECLARE_WORK(work, busymod_work_func); +static DECLARE_COMPLETION (busymod_work_started);static void busymod_work_func (struct work_struct *work) {pr_info ("%s enter\n" , __func__); +complete (&busymod_work_started);while (READ_ONCE (block_transition)) {/*
@@ -37,6 +39,12 @@ static int test_klp_callbacks_busy_init(pr_info ("%s\n" , __func__);schedule_work (&work); +/* +* To synchronize kernel messages, hold the init function from +* exiting until the work function's entry message has printed. +*/ +wait_for_completion (&busymod_work_started); +if (!block_transition) {/* * Serialize output: print all messages from the work
Greg Kroah-Hartman
maintainerPATCH 377/545 profiling: fix shift too large makes kernel panic
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit 0fe6ee8f123a4dfb529a5aff07536bb481f34043 ]
2d186afd04d6 ("profiling: fix shift-out-of-bounds bugs") limits shift value by [0, BITS_PER_LONG -1], which means [0, 63].
However, syzbot found that the max shift value should be the bit number of (_etext - _stext). If shift is outside of this, the "buffer_bytes" will be zero and will cause kzalloc(0). Then the kernel panics due to dereferencing the returned pointer 16.
This can be easily reproduced by passing a large number like 60 to enable profiling and then run readprofile.
LOGS:
BUG: kernel NULL pointer dereference, address: 0000000000000010 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page PGD 6148067 P4D 6148067 PUD 6142067 PMD 0 PREEMPT SMP CPU: 4 PID: 184 Comm: readprofile Not tainted 5.18.0+ #162 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 RIP: 0010:read_profile+0x104/0x220 RSP: 0018:ffffc900006fbe80 EFLAGS: 00000202 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 RDX: ffff888006150000 RSI: 0000000000000001 RDI: ffffffff82aba4a0 RBP: 000000000188bb60 R08: 0000000000000010 R09: ffff888006151000 R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff82aba4a0 R13: 0000000000000000 R14: ffffc900006fbf08 R15: 0000000000020c30 FS: 000000000188a8c0(0000) GS:ffff88803ed00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000010 CR3: 0000000006144000 CR4: 00000000000006e0 Call Trace: <TASK> proc_reg_read+0x56/0x70 vfs_read+0x9a/0x1b0 ksys_read+0xa1/0xe0 ? fpregs_assert_state_consistent+0x1e/0x40 do_syscall_64+0x3a/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 RIP: 0033:0x4d4b4e RSP: 002b:00007ffebb668d58 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 000000000188a8a0 RCX: 00000000004d4b4e RDX: 0000000000000400 RSI: 000000000188bb60 RDI: 0000000000000003 RBP: 0000000000000003 R08: 000000000000006e R09: 0000000000000000 R10: 0000000000000041 R11: 0000000000000246 R12: 000000000188bb60 R13: 0000000000000400 R14: 0000000000000000 R15: 000000000188bb60 </TASK> Modules linked in: CR2: 0000000000000010 Killed ---[ end trace 0000000000000000 ]---
Check prof_len in profile_init() to prevent it be zero.
--- kernel/profile.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/profile.c +7 -0
@@ -109,6 +109,13 @@ int __ref profile_init(void)/* only text is profiled */ prof_len = (_etext - _stext) >> prof_shift; + +if (!prof_len) { +pr_warn ("profiling shift: %u too large\n" , prof_shift); + prof_on =0 ; +return -EINVAL ; + } + buffer_bytes = prof_len*sizeof (atomic_t);if (!alloc_cpumask_var (&prof_cpu_mask,GFP_KERNEL ))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 378/545 ASoC: samsung: h1940_uda1380: include proepr GPIO consumer header
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit bd10b0dafdcf0ec1677cad70101e1f97b9e28f2e ]
h1940_uda1380 uses gpiod*/GPIOD* so it should include GPIO consumer header.
--- sound/soc/samsung/h1940_uda1380.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/samsung/h1940_uda1380.c +1 -1
@@ -8,7 +8,7 @@// Based on version from Arnaud Patard <[email protected]> #include <linux/types.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/module.h> #include <sound/soc.h>
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 379/545 powerpc/perf: Optimize clearing the pending PMI and remove WARN_ON for PMI check in power_pmu_disable
In reply to Greg Kroah-HartmanFrom: Athira Rajeev <[email protected]>
[ Upstream commit 890005a7d98f7452cfe86dcfb2aeeb7df01132ce ]
commit 2c9ac51b850d ("powerpc/perf: Fix PMU callbacks to clear pending PMI before resetting an overflown PMC") added a new function "pmi_irq_pending" in hw_irq.h. This function is to check if there is a PMI marked as pending in Paca (PACA_IRQ_PMI).This is used in power_pmu_disable in a WARN_ON. The intention here is to provide a warning if there is PMI pending, but no counter is found overflown.
During some of the perf runs, below warning is hit:
WARNING: CPU: 36 PID: 0 at arch/powerpc/perf/core-book3s.c:1332 power_pmu_disable+0x25c/0x2c0 Modules linked in: -----
NIP [c000000000141c3c] power_pmu_disable+0x25c/0x2c0 LR [c000000000141c8c] power_pmu_disable+0x2ac/0x2c0
Call Trace: [c000000baffcfb90] [c000000000141c8c] power_pmu_disable+0x2ac/0x2c0 (unreliable) [c000000baffcfc10] [c0000000003e2f8c] perf_pmu_disable+0x4c/0x60 [c000000baffcfc30] [c0000000003e3344] group_sched_out.part.124+0x44/0x100 [c000000baffcfc80] [c0000000003e353c] __perf_event_disable+0x13c/0x240 [c000000baffcfcd0] [c0000000003dd334] event_function+0xc4/0x140 [c000000baffcfd20] [c0000000003d855c] remote_function+0x7c/0xa0 [c000000baffcfd50] [c00000000026c394] flush_smp_call_function_queue+0xd4/0x300 [c000000baffcfde0] [c000000000065b24] smp_ipi_demux_relaxed+0xa4/0x100 [c000000baffcfe20] [c0000000000cb2b0] xive_muxed_ipi_action+0x20/0x40 [c000000baffcfe40] [c000000000207c3c] __handle_irq_event_percpu+0x8c/0x250 [c000000baffcfee0] [c000000000207e2c] handle_irq_event_percpu+0x2c/0xa0 [c000000baffcff10] [c000000000210a04] handle_percpu_irq+0x84/0xc0 [c000000baffcff40] [c000000000205f14] generic_handle_irq+0x54/0x80 [c000000baffcff60] [c000000000015740] __do_irq+0x90/0x1d0 [c000000baffcff90] [c000000000016990] __do_IRQ+0xc0/0x140 [c0000009732f3940] [c000000bafceaca8] 0xc000000bafceaca8 [c0000009732f39d0] [c000000000016b78] do_IRQ+0x168/0x1c0 [c0000009732f3a00] [c0000000000090c8] hardware_interrupt_common_virt+0x218/0x220
This means that there is no PMC overflown among the active events in the PMU, but there is a PMU pending in Paca. The function "any_pmc_overflown" checks the PMCs on active events in cpuhw->n_events. Code snippet:
<<>>
if (any_pmc_overflown(cpuhw))
clear_pmi_irq_pending();
else
WARN_ON(pmi_irq_pending());
<<>>
Here the PMC overflown is not from active event. Example: When we do perf record, default cycles and instructions will be running on PMC6 and PMC5 respectively. It could happen that overflowed event is currently not active and pending PMI is for the inactive event. Debug logs from trace_printk:
<<>>any_pmc_overflown: idx is 5: pmc value is 0xd9apower_pmu_disable: PMC1: 0x0, PMC2: 0x0, PMC3: 0x0, PMC4: 0x0, PMC5: 0xd9a, PMC6: 0x80002011 <<>>
Here active PMC (from idx) is PMC5 , but overflown PMC is PMC6(0x80002011). When we handle PMI interrupt for such cases, if the PMC overflown is from inactive event, it will be ignored. Reference commit:
commit bc09c219b2e6 ("powerpc/perf: Fix finding overflowed PMC in interrupt")
Patch addresses two changes:
1) Fix 1 : Removal of warning ( WARN_ON(pmi_irq_pending()); ) We were printing warning if no PMC is found overflown among active PMU events, but PMI pending in PACA. But this could happen in cases where PMC overflown is not in active PMC. An inactive event could have caused the overflow. Hence the warning is not needed. To know pending PMI is from an inactive event, we need to loop through all PMC's which will cause more SPR reads via mfspr and increase in context switch. Also in existing function: perf_event_interrupt, already we ignore PMI's overflown when it is from an inactive PMC.
2) Fix 2: optimization in clearing pending PMI.
Currently we check for any active PMC overflown before clearing PMI pending in Paca. This is causing additional SPR read also. From point 1, we know that if PMI pending in Paca from inactive cases, that is going to be ignored during replay. Hence if there is pending PMI in Paca, just clear it irrespective of PMC overflown or not.
In summary, remove the any_pmc_overflown check entirely in power_pmu_disable. ie If there is a pending PMI in Paca, clear it, since we are in pmu_disable. There could be cases where PMI is pending because of inactive PMC ( which later when replayed also will get ignored ), so WARN_ON could give false warning. Hence removing it.
--- arch/powerpc/perf/core-book3s.c | 35 ++++++++++++++------------------- 1 file changed, 15 insertions(+), 20 deletions(-)
arch/powerpc/perf/core-book3s.c +15 -20
@@ -1267,27 +1267,22 @@ static void power_pmu_disable(struct pmu *pmu)* a PMI happens during interrupt replay and perf counter * values are cleared by PMU callbacks before replay. * -* If any PMC corresponding to the active PMU events are -* overflown, disable the interrupt by clearing the paca -* bit for PMI since we are disabling the PMU now. -* Otherwise provide a warning if there is PMI pending, but -* no counter is found overflown. +* Disable the interrupt by clearing the paca bit for PMI +* since we are disabling the PMU now. Otherwise provide a +* warning if there is PMI pending, but no counter is found +* overflown. +* +* Since power_pmu_disable runs under local_irq_save, it +* could happen that code hits a PMC overflow without PMI +* pending in paca. Hence only clear PMI pending if it was +* set. +* +* If a PMI is pending, then MSR[EE] must be disabled (because +* the masked PMI handler disabling EE). So it is safe to +* call clear_pmi_irq_pending(). */ -if (any_pmc_overflown (cpuhw)) { -/* -* Since power_pmu_disable runs under local_irq_save, it -* could happen that code hits a PMC overflow without PMI -* pending in paca. Hence only clear PMI pending if it was -* set. -* -* If a PMI is pending, then MSR[EE] must be disabled (because -* the masked PMI handler disabling EE). So it is safe to -* call clear_pmi_irq_pending(). -*/ -if (pmi_irq_pending ()) -clear_pmi_irq_pending (); - }else -WARN_ON (pmi_irq_pending ()); +if (pmi_irq_pending ()) +clear_pmi_irq_pending (); val = mmcra = cpuhw->mmcr.mmcra;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 380/545 ASoC: samsung: change gpiod_speaker_power and rx1950_audio from global to static variables
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
[ Upstream commit d2294461b90e0c5b3bbfaaf2c8baff4fd3e2bb13 ]
sparse reportssound/soc/samsung/rx1950_uda1380.c:131:18: warning: symbol 'gpiod_speaker_power' was not declared. Should it be static? sound/soc/samsung/rx1950_uda1380.c:231:24: warning: symbol 'rx1950_audio' was not declared. Should it be static?
Both gpiod_speaker_power and rx1950_audio are only used in rx1950_uda1380.c, so their storage class specifiers should be static.
--- sound/soc/samsung/rx1950_uda1380.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/samsung/rx1950_uda1380.c +2 -2
@@ -128,7 +128,7 @@ static int rx1950_startup(struct snd_pcm_substream *substream) &hw_rates); } -struct gpio_desc *gpiod_speaker_power; +static struct gpio_desc *gpiod_speaker_power;static int rx1950_spk_power (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event)
@@ -227,7 +227,7 @@ static int rx1950_probe(struct platform_device *pdev)return devm_snd_soc_register_card (dev, &rx1950_asoc); } -struct platform_driver rx1950_audio = { +static struct platform_driver rx1950_audio = { .driver = { .name ="rx1950-audio" , .pm = &snd_soc_pm_ops,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 381/545 tty: n_gsm: Delete gsmtty open SABM frame when config requester
In reply to Greg Kroah-HartmanFrom: Zhenguo Zhao <[email protected]>
[ Upstream commit cbff2b32516881bef30bbebf413d1b49495bab1d ]
When n_gsm config "initiator=0",as requester ,it doesn't need to send SABM frame data during gsmtty open.
Example,when gsmtty open,it will send SABM frame.for initiator,it maybe not want to receive the frame.
[ 88.410426] c1 gsmld_output: 00000000: f9 07 3f 01 de f9 [ 88.420839] c1 --> 1) R: SABM(F)
--- drivers/tty/n_gsm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/tty/n_gsm.c +3 -1
@@ -3024,6 +3024,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp) {struct gsm_dlci *dlci = tty->driver_data;struct tty_port *port = &dlci->port; +struct gsm_mux *gsm = dlci->gsm; port->count++;tty_port_tty_set (port, tty);
@@ -3033,7 +3034,8 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)a DM straight back. This is ok as that will have caused a hangup */ tty_port_set_initialized (port,1 );/* Start sending off SABM messages */ -gsm_dlci_begin_open (dlci); +if (gsm->initiator) +gsm_dlci_begin_open (dlci);/* And wait for virtual carrier */ return tty_port_block_til_ready (port, tty, filp); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 382/545 tty: n_gsm: fix user open not possible at responder until initiator open
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit ac77f0077c3265197d378158c85a55eee6d21508 ]
After setting up the control channel on both sides the responder side may want to open a virtual tty to listen on until the initiator starts an application on a user channel. The current implementation allows the open() but no other operation, like termios. These fail with EINVAL. The responder sided application has no means to detect an open by the initiator sided application this way. And the initiator sided applications usually expect the responder sided application to listen on the user channel upon open.
Set the user channel into half-open state on responder side once a user application opens the virtual tty to allow IO operations on it. Furthermore, keep the user channel constipated until the initiator side opens it to give the responder sided application the chance to detect the new connection and to avoid data loss if the responder sided application starts sending before the user channel is open.
--- drivers/tty/n_gsm.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
drivers/tty/n_gsm.c +29 -2
@@ -1429,6 +1429,8 @@ static void gsm_dlci_close(struct gsm_dlci *dlci)if (debug &8 )pr_debug ("DLCI %d goes closed.\n" , dlci->addr); dlci->state =DLCI_CLOSED ; +/* Prevent us from sending data before the link is up again */ + dlci->constipated = true;if (dlci->addr !=0 ) {tty_port_tty_hangup (&dlci->port, false);spin_lock_irqsave (&dlci->lock, flags);
@@ -1458,6 +1460,7 @@ static void gsm_dlci_open(struct gsm_dlci *dlci)del_timer (&dlci->t1);/* This will let a tty open continue */ dlci->state =DLCI_OPEN ; + dlci->constipated = false;if (debug &8 )pr_debug ("DLCI %d goes open.\n" , dlci->addr);wake_up (&dlci->gsm->event);
@@ -1535,6 +1538,25 @@ static void gsm_dlci_begin_open(struct gsm_dlci *dlci)mod_timer (&dlci->t1, jiffies + gsm->t1 *HZ /100 ); } +/** +* gsm_dlci_set_opening - change state to opening +* @dlci: DLCI to open +* +* Change internal state to wait for DLCI open from initiator side. +* We set off timers and responses upon reception of an SABM. +*/ +static void gsm_dlci_set_opening (struct gsm_dlci *dlci) +{ +switch (dlci->state) { +case DLCI_CLOSED : +case DLCI_CLOSING : + dlci->state =DLCI_OPENING ; +break ; +default : +break ; + } +} +/** * gsm_dlci_begin_close - start channel open procedure * @dlci: DLCI to open
@@ -1673,10 +1695,13 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr) dlci->addr = addr; dlci->adaption = gsm->adaption; dlci->state =DLCI_CLOSED ; -if (addr) +if (addr) { dlci->data = gsm_dlci_data; -else +/* Prevent us from sending data before the link is up */ + dlci->constipated = true; + }else { dlci->data = gsm_dlci_command; + } gsm->dlci[addr] = dlci;return dlci; }
@@ -3036,6 +3061,8 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)/* Start sending off SABM messages */ if (gsm->initiator)gsm_dlci_begin_open (dlci); +else +gsm_dlci_set_opening (dlci);/* And wait for virtual carrier */ return tty_port_block_til_ready (port, tty, filp); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 383/545 tty: n_gsm: fix wrong queuing behavior in gsm_dlci_data_output()
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit 556fc8ac06513cced381588d6d58c184d95cc4fe ]
1) The function drains the fifo for the given user tty/DLCI without considering 'TX_THRESH_HI' and different to gsm_dlci_data_output_framed(), which moves only one packet from the user side to the internal transmission queue. We can only handle one packet at a time here if we want to allow DLCI priority handling in gsm_dlci_data_sweep() to avoid link starvation.
2) Furthermore, the additional header octet from convergence layer type 2 is not counted against MTU. It is part of the UI/UIH frame message which needs to be limited to MTU. Hence, it is wrong not to consider this octet.
3) Finally, the waiting user tty is not informed about freed space in its send queue.
Take at most one packet worth of data out of the DLCI fifo to fix 1). Limit the max user data size per packet to MTU - 1 in case of convergence layer type 2 to leave space for the control signal octet which is added in the later part of the function. This fixes 2).
Add tty_port_tty_wakeup() to wake up the user tty if new write space has been made available to fix 3).
--- drivers/tty/n_gsm.c | 74 +++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 32 deletions(-)
drivers/tty/n_gsm.c +42 -32
@@ -795,41 +795,51 @@ static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci) {struct gsm_msg *msg;u8 *dp; -int len, total_size, size; -int h = dlci->adaption -1 ; +int h, len, size; - total_size =0 ; -while (1 ) { - len =kfifo_len (&dlci->fifo); -if (len ==0 ) -return total_size; - -/* MTU/MRU count only the data bits */ -if (len > gsm->mtu) - len = gsm->mtu; - - size = len + h; - - msg =gsm_data_alloc (gsm, dlci->addr, size, gsm->ftype); -/* FIXME: need a timer or something to kick this so it can't -get stuck with no work outstanding and no buffer free */ -if (msg ==NULL ) -return -ENOMEM ; - dp = msg->data; -switch (dlci->adaption) { -case 1 :/* Unstructured */ -break ; -case 2 :/* Unstructed with modem bits. -Always one byte as we never send inline break data */ - *dp++ = (gsm_encode_modem (dlci) <<1 ) |EA ; -break ; - } -WARN_ON (kfifo_out_locked (&dlci->fifo, dp , len, &dlci->lock) != len); -__gsm_data_queue (dlci, msg); - total_size += size; +/* for modem bits without break data */ + h = ((dlci->adaption ==1 ) ?0 :1 ); + + len =kfifo_len (&dlci->fifo); +if (len ==0 ) +return 0 ; + +/* MTU/MRU count only the data bits but watch adaption mode */ +if ((len + h) > gsm->mtu) + len = gsm->mtu - h; + + size = len + h; + + msg =gsm_data_alloc (gsm, dlci->addr, size, gsm->ftype); +/* FIXME: need a timer or something to kick this so it can't +* get stuck with no work outstanding and no buffer free +*/ +if (!msg) +return -ENOMEM ; + dp = msg->data; +switch (dlci->adaption) { +case 1 :/* Unstructured */ +break ; +case 2 :/* Unstructured with modem bits. +* Always one byte as we never send inline break data +*/ + *dp++ = (gsm_encode_modem (dlci) <<1 ) |EA ; +break ; +default : +pr_err ("%s: unsupported adaption %d\n" , __func__, + dlci->adaption); +break ; } + +WARN_ON (len !=kfifo_out_locked (&dlci->fifo, dp, len, + &dlci->lock)); + +/* Notify upper layer about available send space. */ +tty_port_tty_wakeup (&dlci->port); + +__gsm_data_queue (dlci, msg);/* Bytes of data we used up */ -return total_size; +return size; }/**
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 384/545 tty: n_gsm: fix non flow control frames during mux flow off
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit bec0224816d19abe4fe503586d16d51890540615 ]
n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010.
See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516
The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to
the newer 27.010 here. Chapter 5.4.6.3.6 states that FCoff stops the
transmission on all channels except the control channel. This is already
implemented in gsm_data_kick(). However, chapter 5.4.8.1 explains that this
shall result in the same behavior as software flow control on the ldisc in
advanced option mode. That means only flow control frames shall be sent
during flow off. The current implementation does not consider this case.
Change gsm_data_kick() to send only flow control frames if constipated to abide the standard. gsm_read_ea_val() and gsm_is_flow_ctrl_msg() are introduced as helper functions for this.
It is planned to use gsm_read_ea_val() in later code cleanups for other functions, too.
--- drivers/tty/n_gsm.c | 54 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-)
drivers/tty/n_gsm.c +53 -1
@@ -417,6 +417,27 @@ static int gsm_read_ea(unsigned int *val, u8 c)return c &EA ; } +/** +* gsm_read_ea_val - read a value until EA +* @val: variable holding value +* @data: buffer of data +* @dlen: length of data +* +* Processes an EA value. Updates the passed variable and +* returns the processed data length. +*/ +static unsigned int gsm_read_ea_val (unsigned int *val,const u8 *data,int dlen) +{ +unsigned int len =0 ; + +for (; dlen >0 ; dlen--) { + len++; +if (gsm_read_ea (val, *data++)) +break ; + } +return len; +} +/** * gsm_encode_modem - encode modem data bits * @dlci: DLCI to encode from
@@ -653,6 +674,37 @@ static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len,return m; } +/** +* gsm_is_flow_ctrl_msg - checks if flow control message +* @msg: message to check +* +* Returns true if the given message is a flow control command of the +* control channel. False is returned in any other case. +*/ +static bool gsm_is_flow_ctrl_msg (struct gsm_msg *msg) +{ +unsigned int cmd; + +if (msg->addr >0 ) +return false; + +switch (msg->ctrl & ~PF ) { +case UI : +case UIH : + cmd =0 ; +if (gsm_read_ea_val (&cmd, msg->data +2 , msg->len -2 ) <1 ) +break ; +switch (cmd & ~PF ) { +case CMD_FCOFF : +case CMD_FCON : +return true; + } +break ; + } + +return false; +} +/** * gsm_data_kick - poke the queue * @gsm: GSM Mux
@@ -671,7 +723,7 @@ static void gsm_data_kick(struct gsm_mux *gsm, struct gsm_dlci *dlci)int len;list_for_each_entry_safe (msg, nmsg, &gsm->tx_list, list) { -if (gsm->constipated && msg->addr) +if (gsm->constipated && !gsm_is_flow_ctrl_msg (msg))continue ;if (gsm->encoding !=0 ) { gsm->txframe[0 ] =GSM1_SOF ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 385/545 tty: n_gsm: fix packet re-transmission without open control channel
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit 4fae831b3a71fc5a44cc5c7d0b8c1267ee7659f5 ]
In the current implementation control packets are re-transmitted even if the control channel closed down during T2. This is wrong. Check whether the control channel is open before re-transmitting any packets. Note that control channel open/close is handled by T1 and not T2 and remains unaffected by this.
--- drivers/tty/n_gsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/n_gsm.c +1 -1
@@ -1388,7 +1388,7 @@ static void gsm_control_retransmit(struct timer_list *t)spin_lock_irqsave (&gsm->control_lock, flags); ctrl = gsm->pending_cmd;if (ctrl) { -if (gsm->cretries ==0 ) { +if (gsm->cretries ==0 || !gsm->dlci[0 ] || gsm->dlci[0 ]->dead) { gsm->pending_cmd =NULL ; ctrl->error = -ETIMEDOUT ; ctrl->done =1 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 386/545 tty: n_gsm: fix race condition in gsmld_write()
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit 32dd59f96924f45e33bc79854f7a00679c0fa28e ]
The function may be used by the user directly and also by the n_gsm internal functions. They can lead into a race condition which results in interleaved frames if both are writing at the same time. The receiving side is not able to decode those interleaved frames correctly.
Add a lock around the low side tty write to avoid race conditions and frame interleaving between user originated writes and n_gsm writes.
--- drivers/tty/n_gsm.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/tty/n_gsm.c +17 -4
@@ -2705,11 +2705,24 @@ static ssize_t gsmld_read(struct tty_struct *tty, struct file *file,static ssize_t gsmld_write (struct tty_struct *tty,struct file *file,const unsigned char *buf,size_t nr) { -int space =tty_write_room (tty); +struct gsm_mux *gsm = tty->disc_data; +unsigned long flags; +int space; +int ret; + +if (!gsm) +return -ENODEV ; + + ret = -ENOBUFS ; +spin_lock_irqsave (&gsm->tx_lock, flags); + space =tty_write_room (tty);if (space >= nr) -return tty->ops->write (tty, buf, nr); -set_bit (TTY_DO_WRITE_WAKEUP , &tty->flags); -return -ENOBUFS ; + ret = tty->ops->write (tty, buf, nr); +else +set_bit (TTY_DO_WRITE_WAKEUP , &tty->flags); +spin_unlock_irqrestore (&gsm->tx_lock, flags); + +return ret; }/**
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 387/545 ASoC: qcom: Fix missing of_node_put() in asoc_qcom_lpass_cpu_platform_probe()
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit f507c0c67dac57d2bcd5dcae4b6139b0305d8957 ]
We should call of_node_put() for the reference 'dsp_of_node' returned by of_parse_phandle() which will increase the refcount.
--- sound/soc/qcom/lpass-cpu.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/qcom/lpass-cpu.c +1 -0
@@ -846,6 +846,7 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev) dsp_of_node =of_parse_phandle (pdev->dev.of_node,"qcom,adsp" ,0 );if (dsp_of_node) {dev_err (dev,"DSP exists and holds audio resources\n" ); +of_node_put (dsp_of_node);return -EBUSY ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 388/545 remoteproc: qcom: wcnss: Fix handling of IRQs
In reply to Greg Kroah-HartmanFrom: Sireesh Kodali <[email protected]>
[ Upstream commit bed0adac1ded4cb486ba19a3a7e730fbd9a1c9c6 ]
The wcnss_get_irq function is expected to return a value > 0 in the event that an IRQ is succssfully obtained, but it instead returns 0. This causes the stop and ready IRQs to never actually be used despite being defined in the device-tree. This patch fixes that.
--- drivers/remoteproc/qcom_wcnss.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/remoteproc/qcom_wcnss.c +8 -2
@@ -415,6 +415,7 @@ static int wcnss_request_irq(struct qcom_wcnss *wcnss, irq_handler_t thread_fn) {int ret; +int irq_number; ret =platform_get_irq_byname (pdev, name);if (ret <0 && optional) {
@@ -425,14 +426,19 @@ static int wcnss_request_irq(struct qcom_wcnss *wcnss,return ret; } + irq_number = ret; + ret =devm_request_threaded_irq (&pdev->dev, ret,NULL , thread_fn,IRQF_TRIGGER_RISING |IRQF_ONESHOT ,"wcnss" , wcnss); -if (ret) +if (ret) {dev_err (&pdev->dev,"request %s IRQ failed\n" , name); +return ret; + } -return ret; +/* Return the IRQ number if the IRQ was successfully acquired */ +return irq_number; }static int wcnss_alloc_memory_region (struct qcom_wcnss *wcnss)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 389/545 vfio: Remove extra put/gets around vfio_device->group
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit e572bfb2b6a83b05acd30c03010e661b1967960f ]
The vfio_device->group value has a get obtained during vfio_add_group_dev() which gets moved from the stack to vfio_device->group in vfio_group_create_device().
The reference remains until we reach the end of vfio_del_group_dev() when it is put back.
Thus anything that already has a kref on the vfio_device is guaranteed a valid group pointer. Remove all the extra reference traffic.
It is tricky to see, but the get at the start of vfio_del_group_dev() is actually pairing with the put hidden inside vfio_device_put() a few lines below.
A later patch merges vfio_group_create_device() into vfio_add_group_dev() which makes the ownership and error flow on the create side easier to follow.
Message-Id: <[email protected]>
--- drivers/vfio/vfio.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)
drivers/vfio/vfio.c +2 -19
@@ -546,14 +546,12 @@ struct vfio_device *vfio_group_create_device(struct vfio_group *group,kref_init (&device->kref); device->dev = dev; +/* Our reference on group is moved to the device */ device->group = group; device->ops = ops; device->device_data = device_data;dev_set_drvdata (dev, device); -/* No need to get group_lock, caller has group reference */ -vfio_group_get (group); -mutex_lock (&group->device_lock);list_add (&device->group_next, &group->device_list); group->dev_counter++;
@@ -585,13 +583,11 @@ void vfio_device_put(struct vfio_device *device) {struct vfio_group *group = device->group;kref_put_mutex (&device->kref, vfio_device_release, &group->device_lock); -vfio_group_put (group); }EXPORT_SYMBOL_GPL (vfio_device_put);static void vfio_device_get (struct vfio_device *device) { -vfio_group_get (device->group);kref_get (&device->kref); }
@@ -841,14 +837,6 @@ int vfio_add_group_dev(struct device *dev,vfio_group_put (group);return PTR_ERR (device); } - -/* -* Drop all but the vfio_device reference. The vfio_device holds -* a reference to the vfio_group, which holds a reference to the -* iommu_group. -*/ -vfio_group_put (group); -return 0 ; }EXPORT_SYMBOL_GPL (vfio_add_group_dev);
@@ -928,12 +916,6 @@ void *vfio_del_group_dev(struct device *dev)unsigned int i =0 ;bool interrupted = false; -/* -* The group exists so long as we have a device reference. Get -* a group reference and use it to scan for the device going away. -*/ -vfio_group_get (group); -/* * When the device is removed from the group, the group suddenly * becomes non-viable; the device has a driver (until the unbind
@@ -1008,6 +990,7 @@ void *vfio_del_group_dev(struct device *dev)if (list_empty (&group->device_list))wait_event (group->container_q, !group->container); +/* Matches the get in vfio_group_create_device() */ vfio_group_put (group);return device_data;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 390/545 vfio: Simplify the lifetime logic for vfio_device
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 5e42c999445bd0ae86e35affeb3e7c473d74a893 ]
The vfio_device is using a 'sleep until all refs go to zero' pattern for its lifetime, but it is indirectly coded by repeatedly scanning the group list waiting for the device to be removed on its own.
Switch this around to be a direct representation, use a refcount to count the number of places that are blocking destruction and sleep directly on a completion until that counter goes to zero. kfree the device after other accesses have been excluded in vfio_del_group_dev(). This is a fairly common Linux idiom.
Due to this we can now remove kref_put_mutex(), which is very rarely used in the kernel. Here it is being used to prevent a zero ref device from being seen in the group list. Instead allow the zero ref device to continue to exist in the device_list and use refcount_inc_not_zero() to exclude it once refs go to zero.
This patch is organized so the next patch will be able to alter the API to allow drivers to provide the kfree.
Message-Id: <[email protected]>
--- drivers/vfio/vfio.c | 79 ++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 54 deletions(-)
drivers/vfio/vfio.c +25 -54
@@ -46,7 +46,6 @@ static struct vfio {struct mutex group_lock;struct cdev group_cdev;dev_t group_devt; -wait_queue_head_t release_q; } vfio;struct vfio_iommu_driver {
@@ -91,7 +90,8 @@ struct vfio_group { };struct vfio_device { -struct kref kref; +refcount_t refcount; +struct completion comp;struct device *dev;const struct vfio_device_ops *ops;struct vfio_group *group;
@@ -544,7 +544,8 @@ struct vfio_device *vfio_group_create_device(struct vfio_group *group,if (!device)return ERR_PTR (-ENOMEM ); -kref_init (&device->kref); +refcount_set (&device->refcount,1 ); +init_completion (&device->comp); device->dev = dev;/* Our reference on group is moved to the device */ device->group = group;
@@ -560,35 +561,17 @@ struct vfio_device *vfio_group_create_device(struct vfio_group *group,return device; } -static void vfio_device_release (struct kref *kref) -{ -struct vfio_device *device =container_of (kref, - struct vfio_device, kref); -struct vfio_group *group = device->group; - -list_del (&device->group_next); - group->dev_counter--; -mutex_unlock (&group->device_lock); - -dev_set_drvdata (device->dev,NULL ); - -kfree (device); - -/* vfio_del_group_dev may be waiting for this device */ -wake_up (&vfio.release_q); -} -/* Device reference always implies a group reference */ void vfio_device_put (struct vfio_device *device) { -struct vfio_group *group = device->group; -kref_put_mutex (&device->kref, vfio_device_release, &group->device_lock); +if (refcount_dec_and_test (&device->refcount)) +complete (&device->comp); }EXPORT_SYMBOL_GPL (vfio_device_put); -static void vfio_device_get (struct vfio_device *device) +static bool vfio_device_try_get (struct vfio_device *device) { -kref_get (&device->kref); +return refcount_inc_not_zero (&device->refcount); } static struct vfio_device *vfio_group_get_device(struct vfio_group *group,
@@ -598,8 +581,7 @@ static struct vfio_device *vfio_group_get_device(struct vfio_group *group,mutex_lock (&group->device_lock);list_for_each_entry (device, &group->device_list, group_next) { -if (device->dev == dev) { -vfio_device_get (device); +if (device->dev == dev &&vfio_device_try_get (device)) {mutex_unlock (&group->device_lock);return device; }
@@ -883,9 +865,8 @@ static struct vfio_device *vfio_device_get_from_name(struct vfio_group *group, ret = !strcmp (dev_name (it->dev), buf); } -if (ret) { +if (ret &&vfio_device_try_get (it)) { device = it; -vfio_device_get (device);break ; } }
@@ -908,13 +889,13 @@ EXPORT_SYMBOL_GPL(vfio_device_data);* removed. Open file descriptors for the device... */ void *vfio_del_group_dev (struct device *dev) { -DEFINE_WAIT_FUNC (wait, woken_wake_function);struct vfio_device *device =dev_get_drvdata (dev);struct vfio_group *group = device->group;void *device_data = device->device_data;struct vfio_unbound_dev *unbound;unsigned int i =0 ;bool interrupted = false; +long rc;/* * When the device is removed from the group, the group suddenly
@@ -935,32 +916,18 @@ void *vfio_del_group_dev(struct device *dev)WARN_ON (!unbound);vfio_device_put (device); - -/* -* If the device is still present in the group after the above -* 'put', then it is in use and we need to request it from the -* bus driver. The driver may in turn need to request the -* device from the user. We send the request on an arbitrary -* interval with counter to allow the driver to take escalating -* measures to release the device if it has the ability to do so. -*/ -add_wait_queue (&vfio.release_q, &wait); - - do { - device = vfio_group_get_device(group, dev); - if (!device) - break; - + rc =try_wait_for_completion (&device->comp); +while (rc <=0 ) {if (device->ops->request) device->ops->request (device_data, i++); - vfio_device_put(device); -if (interrupted) { - wait_woken(&wait, TASK_UNINTERRUPTIBLE, HZ * 10); + rc =wait_for_completion_timeout (&device->comp, +HZ *10 ); }else { - wait_woken(&wait, TASK_INTERRUPTIBLE, HZ * 10); - if (signal_pending(current)) { + rc =wait_for_completion_interruptible_timeout ( + &device->comp,HZ *10 ); +if (rc <0 ) { interrupted = true;dev_warn (dev, "Device is currently in use, task"
@@ -969,10 +936,13 @@ void *vfio_del_group_dev(struct device *dev) current->comm, task_pid_nr(current)); } } + } - }while (1 ); +mutex_lock (&group->device_lock); +list_del (&device->group_next); + group->dev_counter--; +mutex_unlock (&group->device_lock); -remove_wait_queue (&vfio.release_q, &wait);/* * In order to support multiple devices per group, devices can be * plucked from the group while other devices in the group are still
@@ -992,6 +962,8 @@ void *vfio_del_group_dev(struct device *dev)/* Matches the get in vfio_group_create_device() */ vfio_group_put (group); +dev_set_drvdata (dev,NULL ); +kfree (device);return device_data; }
@@ -2339,7 +2311,6 @@ static int __init vfio_init(void)mutex_init (&vfio.iommu_drivers_lock);INIT_LIST_HEAD (&vfio.group_list);INIT_LIST_HEAD (&vfio.iommu_drivers_list); -init_waitqueue_head (&vfio.release_q); ret =misc_register (&vfio_dev);if (ret) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 391/545 vfio: Split creation of a vfio_device into init and register ops
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 0bfc6a4ea63c2adac71a824397ef48f28dbc5e47 ]
This makes the struct vfio_device part of the public interface so it can be used with container_of and so forth, as is typical for a Linux subystem.
This is the first step to bring some type-safety to the vfio interface by allowing the replacement of 'void *' and 'struct device *' inputs with a simple and clear 'struct vfio_device *'
For now the self-allocating vfio_add_group_dev() interface is kept so each user can be updated as a separate patch.
The expected usage pattern is
driver core probe() function:
my_device = kzalloc(sizeof(*mydevice));
vfio_init_group_dev(&my_device->vdev, dev, ops, mydevice);
/* other driver specific prep */
vfio_register_group_dev(&my_device->vdev);
dev_set_drvdata(dev, my_device);
driver core remove() function:
my_device = dev_get_drvdata(dev);
vfio_unregister_group_dev(&my_device->vdev);
/* other driver specific tear down */
kfree(my_device);Allowing the driver to be able to use the drvdata and vfio_device to go to/from its own data.
The pattern also makes it clear that vfio_register_group_dev() must be last in the sequence, as once it is called the core code can immediately start calling ops. The init/register gap is provided to allow for the driver to do setup before ops can be called and thus avoid races.
Message-Id: <[email protected]>
--- Documentation/driver-api/vfio.rst | 31 ++++---- drivers/vfio/vfio.c | 125 ++++++++++++++++-------------- include/linux/vfio.h | 16 ++++ 3 files changed, 99 insertions(+), 73 deletions(-)
Documentation/driver-api/vfio.rst +18 -13
@@ -249,18 +249,23 @@ VFIO bus driver API VFIO bus drivers, such as vfio-pci make use of only a few interfaces into VFIO core. When devices are bound and unbound to the driver, -the driver should call vfio_add_group_dev() and vfio_del_group_dev() -respectively:: - - extern int vfio_add_group_dev(struct device *dev, - const struct vfio_device_ops *ops, - void *device_data); - - extern void *vfio_del_group_dev(struct device *dev); - -vfio_add_group_dev() indicates to the core to begin tracking the -iommu_group of the specified dev and register the dev as owned by -a VFIO bus driver. The driver provides an ops structure for callbacks +the driver should call vfio_register_group_dev() and +vfio_unregister_group_dev() respectively:: + + void vfio_init_group_dev(struct vfio_device *device, + struct device *dev, + const struct vfio_device_ops *ops, + void *device_data); + int vfio_register_group_dev(struct vfio_device *device); + void vfio_unregister_group_dev(struct vfio_device *device); + +The driver should embed the vfio_device in its own structure and call +vfio_init_group_dev() to pre-configure it before going to registration. +vfio_register_group_dev() indicates to the core to begin tracking the +iommu_group of the specified dev and register the dev as owned by a VFIO bus +driver. Once vfio_register_group_dev() returns it is possible for userspace to +start accessing the driver, thus the driver should ensure it is completely +ready before calling it. The driver provides an ops structure for callbacks similar to a file operations structure:: struct vfio_device_ops {
@@ -276,7 +281,7 @@ similar to a file operations structure:: }; Each function is passed the device_data that was originally registered -in the vfio_add_group_dev() call above. This allows the bus driver +in the vfio_register_group_dev() call above. This allows the bus driver an easy place to store its opaque, private data. The open/release callbacks are issued when a new file descriptor is created for a device (via VFIO_GROUP_GET_DEVICE_FD). The ioctl interface provides
drivers/vfio/vfio.c +65 -60
194 lines not on this page · raw message
include/linux/vfio.h +16 -0
@@ -15,6 +15,18 @@#include <linux/poll.h> #include <uapi/linux/vfio.h> +struct vfio_device { +struct device *dev; +const struct vfio_device_ops *ops; +struct vfio_group *group; + +/* Members below here are private, not for driver use */ +refcount_t refcount; +struct completion comp; +struct list_head group_next; +void *device_data; +}; +/** * struct vfio_device_ops - VFIO bus driver device callbacks *
@@ -48,11 +60,15 @@ struct vfio_device_ops {extern struct iommu_group *vfio_iommu_group_get (struct device *dev);extern void vfio_iommu_group_put (struct iommu_group *group,struct device *dev); +void vfio_init_group_dev (struct vfio_device *device,struct device *dev, +const struct vfio_device_ops *ops,void *device_data); +int vfio_register_group_dev (struct vfio_device *device);extern int vfio_add_group_dev (struct device *dev,const struct vfio_device_ops *ops,void *device_data);extern void *vfio_del_group_dev (struct device *dev); +void vfio_unregister_group_dev (struct vfio_device *device);extern struct vfio_device *vfio_device_get_from_dev (struct device *dev);extern void vfio_device_put (struct vfio_device *device);extern void *vfio_device_data (struct vfio_device *device);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 392/545 vfio/mdev: Make to_mdev_device() into a static inline
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 66873b5fa738ca02b5c075ca4a410b13d88e6e9a ]
The macro wrongly uses 'dev' as both the macro argument and the member name, which means it fails compilation if any caller uses a word other than 'dev' as the single argument. Fix this defect by making it into proper static inline, which is more clear and typesafe anyhow.
Message-Id: <[email protected]>
--- drivers/vfio/mdev/mdev_private.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/vfio/mdev/mdev_private.h +4 -1
@@ -35,7 +35,10 @@ struct mdev_device {bool active; }; -#define to_mdev_device (dev) container_of(dev, struct mdev_device, dev) +static inline struct mdev_device *to_mdev_device (struct device *dev) +{ + return container_of(dev, struct mdev_device, dev); +}#define dev_is_mdev (d) ((d)->bus == &mdev_bus_type)struct mdev_type {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 393/545 vfio/ccw: Do not change FSM state in subchannel event
In reply to Greg Kroah-HartmanFrom: Eric Farman <[email protected]>
[ Upstream commit cffcc109fd682075dee79bade3d60a07152a8fd1 ]
The routine vfio_ccw_sch_event() is tasked with handling subchannel events, specifically machine checks, on behalf of vfio-ccw. It correctly calls cio_update_schib(), and if that fails (meaning the subchannel is gone) it makes an FSM event call to mark the subchannel Not Operational.
If that worked, however, then it decides that if the FSM state was already Not Operational (implying the subchannel just came back), then it should simply change the FSM to partially- or fully-open.
Remove this trickery, since a subchannel returning will require more probing than simply "oh all is well again" to ensure it works correctly.
--- drivers/s390/cio/vfio_ccw_drv.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/s390/cio/vfio_ccw_drv.c +3 -11
@@ -288,19 +288,11 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)if (work_pending (&sch->todo_work)) goto out_unlock; -if (cio_update_schib (sch)) { -vfio_ccw_fsm_event (private,VFIO_CCW_EVENT_NOT_OPER ); - rc =0 ; - goto out_unlock; - } - - private =dev_get_drvdata (&sch->dev); -if (private->state ==VFIO_CCW_STATE_NOT_OPER ) { - private->state = private->mdev ?VFIO_CCW_STATE_IDLE : -VFIO_CCW_STATE_STANDBY ; - } rc =0 ; +if (cio_update_schib (sch)) +vfio_ccw_fsm_event (private,VFIO_CCW_EVENT_NOT_OPER ); + out_unlock:spin_unlock_irqrestore (sch->lock, flags);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 394/545 tty: n_gsm: fix wrong T1 retry count handling
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit f30e10caa80aa1f35508bc17fc302dbbde9a833c ]
n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010.
See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516
The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to
the newer 27.010 here. Chapter 5.7.3 states that the valid range for the
maximum number of retransmissions (N2) is from 0 to 255 (both including).gsm_dlci_t1() handles this number incorrectly by performing N2 - 1
retransmission attempts. Setting N2 to zero results in more than 255
retransmission attempts.
Fix gsm_dlci_t1() to comply with 3GPP 27.010.
--- drivers/tty/n_gsm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/n_gsm.c +2 -2
@@ -1550,8 +1550,8 @@ static void gsm_dlci_t1(struct timer_list *t)switch (dlci->state) {case DLCI_OPENING : - dlci->retries--;if (dlci->retries) { + dlci->retries--;gsm_command (dlci->gsm, dlci->addr,SABM |PF );mod_timer (&dlci->t1, jiffies + gsm->t1 *HZ /100 ); }else if (!dlci->addr && gsm->control == (DM |PF )) {
@@ -1566,8 +1566,8 @@ static void gsm_dlci_t1(struct timer_list *t)break ;case DLCI_CLOSING : - dlci->retries--;if (dlci->retries) { + dlci->retries--;gsm_command (dlci->gsm, dlci->addr,DISC |PF );mod_timer (&dlci->t1, jiffies + gsm->t1 *HZ /100 ); }else
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 395/545 tty: n_gsm: fix DM command
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit 18a948c7d90995d127785e308fa7b701df4c499f ]
n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010.
See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516
The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to
the newer 27.010 here. Chapter 5.3.3 defines the DM response. There exists
no DM command. However, the current implementation incorrectly sends DM as
command in case of unexpected UIH frames in gsm_queue().
Correct this behavior by always sending DM as response.
--- drivers/tty/n_gsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/n_gsm.c +1 -1
@@ -1938,7 +1938,7 @@ static void gsm_queue(struct gsm_mux *gsm) goto invalid;#endif if (dlci ==NULL || dlci->state !=DLCI_OPEN ) { -gsm_command (gsm, address,DM |PF ); +gsm_response (gsm, address,DM |PF );return ; } dlci->data (dlci, gsm->buf, gsm->len);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 396/545 tty: n_gsm: fix missing corner cases in gsmld_poll()
In reply to Greg Kroah-HartmanFrom: Daniel Starke <[email protected]>
[ Upstream commit 7e5b4322cde067e1d0f1bf8f490e93f664a7c843 ]
gsmld_poll() currently fails to handle the following corner cases correctly:
- remote party closed the associated tty
Add the missing checks and map those to EPOLLHUP. Reorder the checks to group them by their reaction.
--- drivers/tty/n_gsm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/tty/n_gsm.c +5 -2
@@ -2747,12 +2747,15 @@ static __poll_t gsmld_poll(struct tty_struct *tty, struct file *file,poll_wait (file, &tty->read_wait, wait);poll_wait (file, &tty->write_wait, wait); + +if (gsm->dead) + mask |=EPOLLHUP ;if (tty_hung_up_p (file)) mask |=EPOLLHUP ; +if (test_bit (TTY_OTHER_CLOSED , &tty->flags)) + mask |=EPOLLHUP ;if (!tty_is_writelocked (tty) &&tty_write_room (tty) >0 ) mask |=EPOLLOUT |EPOLLWRNORM ; -if (gsm->dead) - mask |=EPOLLHUP ;return mask; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 397/545 iommu/exynos: Handle failed IOMMU device registration properly
In reply to Greg Kroah-HartmanFrom: Sam Protsenko <[email protected]>
[ Upstream commit fce398d2d02c0a9a2bedf7c7201b123e153e8963 ]
If iommu_device_register() fails in exynos_sysmmu_probe(), the previous calls have to be cleaned up. In this case, the iommu_device_sysfs_add() should be cleaned up, by calling its remove counterpart call.
--- drivers/iommu/exynos-iommu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iommu/exynos-iommu.c +5 -1
@@ -635,7 +635,7 @@ static int exynos_sysmmu_probe(struct platform_device *pdev) ret =iommu_device_register (&data->iommu);if (ret) -return ret; + goto err_iommu_register;platform_set_drvdata (pdev, data);
@@ -662,6 +662,10 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)pm_runtime_enable (dev);return 0 ; + +err_iommu_register: +iommu_device_sysfs_remove (&data->iommu); +return ret; }static int __maybe_unused exynos_sysmmu_suspend (struct device *dev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 398/545 rpmsg: qcom_smd: Fix refcount leak in qcom_smd_parse_edge
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 65382585f067d4256ba087934f30f85c9b6984de ]
of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when done.
--- drivers/rpmsg/qcom_smd.c | 1 + 1 file changed, 1 insertion(+)
drivers/rpmsg/qcom_smd.c +1 -0
@@ -1364,6 +1364,7 @@ static int qcom_smd_parse_edge(struct device *dev, } edge->ipc_regmap =syscon_node_to_regmap (syscon_np); +of_node_put (syscon_np);if (IS_ERR (edge->ipc_regmap)) { ret =PTR_ERR (edge->ipc_regmap); goto put_node;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 399/545 kfifo: fix kfifo_to_user() return type
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 045ed31e23aea840648c290dbde04797064960db ]
The kfifo_to_user() macro is supposed to return zero for success or negative error codes. Unfortunately, there is a signedness bug so it returns unsigned int. This only affects callers which try to save the result in ssize_t and as far as I can see the only place which does that is line6_hwdep_read().
TL;DR: s/_uint/_int/.
--- include/linux/kfifo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/kfifo.h +1 -1
@@ -688,7 +688,7 @@ __kfifo_uint_must_check_helper( \* writer, you don't need extra locking to use these macro. */ #define kfifo_to_user (fifo, to, len, copied) \ -__kfifo_uint_must_check_helper( \ +__kfifo_int_must_check_helper( \ ({ \ typeof((fifo) + 1) __tmp = (fifo); \ void __user *__to = (to); \
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 400/545 lib/smp_processor_id: fix imbalanced instrumentation_end() call
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
[ Upstream commit bd27acaac24e4b252ee28dddcabaee80456d0faf ]
Currently instrumentation_end() won't be called if printk_ratelimit() returned false.
--- lib/smp_processor_id.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/smp_processor_id.c +1 -1
@@ -46,9 +46,9 @@ unsigned int check_preemption_disabled(const char *what1, const char *what2)printk ("caller is %pS\n" ,__builtin_return_address (0 ));dump_stack (); -instrumentation_end (); out_enable: +instrumentation_end ();preempt_enable_no_resched_notrace (); out:return this_cpu;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 401/545 remoteproc: sysmon: Wait for SSCTL service to come up
In reply to Greg Kroah-HartmanFrom: Sibi Sankar <[email protected]>
[ Upstream commit 47c04e00eff86a81cd357c3feed04c86089bcb85 ]
The SSCTL service comes up after a finite time when the remote Q6 comes out of reset. Any graceful shutdowns requested during this period will be a NOP and abrupt tearing down of the glink channel might lead to pending transactions on the remote Q6 side and will ultimately lead to a fatal error. Fix this by waiting for the SSCTL service when a graceful shutdown is requested.
--- drivers/remoteproc/qcom_sysmon.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/remoteproc/qcom_sysmon.c +10 -0
@@ -41,6 +41,7 @@ struct qcom_sysmon {struct completion comp;struct completion ind_comp;struct completion shutdown_comp; +struct completion ssctl_comp;struct mutex lock;bool ssr_ack;
@@ -422,6 +423,8 @@ static int ssctl_new_server(struct qmi_handle *qmi, struct qmi_service *svc) svc->priv = sysmon; +complete (&sysmon->ssctl_comp); +return 0 ; }
@@ -478,6 +481,7 @@ static int sysmon_start(struct rproc_subdev *subdev) .ssr_event = SSCTL_SSR_EVENT_AFTER_POWERUP }; +reinit_completion (&sysmon->ssctl_comp);mutex_lock (&sysmon->state_lock); sysmon->state =SSCTL_SSR_EVENT_AFTER_POWERUP ;blocking_notifier_call_chain (&sysmon_notifiers,0 , (void *)&event);
@@ -520,6 +524,11 @@ static void sysmon_stop(struct rproc_subdev *subdev, bool crashed)if (crashed)return ; +if (sysmon->ssctl_instance) { +if (!wait_for_completion_timeout (&sysmon->ssctl_comp,HZ /2 )) +dev_err (sysmon->dev,"timeout waiting for ssctl service\n" ); + } +if (sysmon->ssctl_version)ssctl_request_shutdown (sysmon);else if (sysmon->ept)
@@ -606,6 +615,7 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,init_completion (&sysmon->comp);init_completion (&sysmon->ind_comp);init_completion (&sysmon->shutdown_comp); +init_completion (&sysmon->ssctl_comp);mutex_init (&sysmon->lock);mutex_init (&sysmon->state_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 402/545 mfd: t7l66xb: Drop platform disable callback
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 128ac294e1b437cb8a7f2ff8ede1cde9082bddbe ]
None of the in-tree instantiations of struct t7l66xb_platform_data provides a disable callback. So better don't dereference this function pointer unconditionally. As there is no user, drop it completely instead of calling it conditional.
This is a preparation for making platform remove callbacks return void.
--- drivers/mfd/t7l66xb.c | 6 +----- include/linux/mfd/t7l66xb.h | 1 - 2 files changed, 1 insertion(+), 6 deletions(-)
drivers/mfd/t7l66xb.c +1 -5
@@ -405,11 +405,8 @@ static int t7l66xb_probe(struct platform_device *dev)static int t7l66xb_remove (struct platform_device *dev) { -struct t7l66xb_platform_data *pdata =dev_get_platdata (&dev->dev);struct t7l66xb *t7l66xb =platform_get_drvdata (dev); -int ret; - ret = pdata->disable (dev);clk_disable_unprepare (t7l66xb->clk48m);clk_put (t7l66xb->clk48m);clk_disable_unprepare (t7l66xb->clk32k);
@@ -420,8 +417,7 @@ static int t7l66xb_remove(struct platform_device *dev)mfd_remove_devices (&dev->dev);kfree (t7l66xb); -return ret; - +return 0 ; }static struct platform_driver t7l66xb_platform_driver = {
include/linux/mfd/t7l66xb.h +0 -1
@@ -12,7 +12,6 @@struct t7l66xb_platform_data {int (*enable)(struct platform_device *dev); -int (*disable)(struct platform_device *dev);int (*suspend)(struct platform_device *dev);int (*resume)(struct platform_device *dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 403/545 mfd: max77620: Fix refcount leak in max77620_initialise_fps
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 1520669c8255bd637c6b248b2be910e2688d38dd ]
of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak.
--- drivers/mfd/max77620.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mfd/max77620.c +2 -0
@@ -419,9 +419,11 @@ static int max77620_initialise_fps(struct max77620_chip *chip) ret =max77620_config_fps (chip, fps_child);if (ret <0 ) {of_node_put (fps_child); +of_node_put (fps_np);return ret; } } +of_node_put (fps_np); config = chip->enable_global_lpm ?MAX77620_ONOFFCNFG2_SLP_LPM_MSK :0 ; ret = regmap_update_bits(chip->rmap, MAX77620_REG_ONOFFCNFG2,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 404/545 iommu/arm-smmu: qcom_iommu: Add of_node_put() when breaking out of loop
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit a91eb6803c1c715738682fece095145cbd68fe0b ]
In qcom_iommu_has_secure_context(), we should call of_node_put() for the reference 'child' when breaking out of for_each_child_of_node() which will automatically increase and decrease the refcount.
--- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu/qcom_iommu.c +5 -2
@@ -766,9 +766,12 @@ static bool qcom_iommu_has_secure_context(struct qcom_iommu_dev *qcom_iommu) {struct device_node *child; -for_each_child_of_node (qcom_iommu->dev->of_node, child) -if (of_device_is_compatible (child,"qcom,msm-iommu-v1-sec" )) +for_each_child_of_node (qcom_iommu->dev->of_node, child) { +if (of_device_is_compatible (child,"qcom,msm-iommu-v1-sec" )) { +of_node_put (child);return true; + } + }return false; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 405/545 perf tools: Fix dso_id inode generation comparison
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
[ Upstream commit 68566a7cf56bf3148797c218ed45a9de078ef47c ]
Synthesized MMAP events have zero ino_generation, so do not compare them to DSOs with a real ino_generation otherwise we end up with a DSO without a build id.
--- tools/perf/util/dsos.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
tools/perf/util/dsos.c +13 -2
@@ -20,8 +20,19 @@ static int __dso_id__cmp(struct dso_id *a, struct dso_id *b)if (a->ino > b->ino)return -1 ;if (a->ino < b->ino)return 1 ; -if (a->ino_generation > b->ino_generation)return -1 ; -if (a->ino_generation < b->ino_generation)return 1 ; +/* +* Synthesized MMAP events have zero ino_generation, avoid comparing +* them with MMAP events with actual ino_generation. +* +* I found it harmful because the mismatch resulted in a new +* dso that did not have a build ID whereas the original dso did have a +* build ID. The build ID was essential because the object was not found +* otherwise. - Adrian +*/ +if (a->ino_generation && b->ino_generation) { +if (a->ino_generation > b->ino_generation)return -1 ; +if (a->ino_generation < b->ino_generation)return 1 ; + }return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 406/545 s390/dump: fix old lowcore virtual vs physical address confusion
In reply to Greg Kroah-HartmanFrom: Alexander Gordeev <[email protected]>
[ Upstream commit dc306186a130c6d9feb0aabc1c71b8ed1674a3bf ]
Virtual addresses of vmcore_info and os_info members are wrongly passed to copy_oldmem_kernel(), while the function expects physical address of the source. Instead, __pa() macro should have been applied.
Yet, use of __pa() macro could be somehow confusing, since copy_oldmem_kernel() may treat the source as an offset, not as a direct physical address (that depens from the oldmem availability and location).
Fix the virtual vs physical address confusion and make the way the old lowcore is read consistent across all sources.
--- arch/s390/kernel/asm-offsets.c | 2 ++ arch/s390/kernel/crash_dump.c | 2 +- arch/s390/kernel/os_info.c | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-)
arch/s390/kernel/asm-offsets.c +2 -0
@@ -150,6 +150,8 @@ int main(void)OFFSET (__LC_BR_R1, lowcore, br_r1_trampoline);/* software defined ABI-relevant lowcore locations 0xe00 - 0xe20 */ OFFSET (__LC_DUMP_REIPL, lowcore, ipib); +OFFSET (__LC_VMCORE_INFO, lowcore, vmcore_info); +OFFSET (__LC_OS_INFO, lowcore, os_info);/* hardware defined lowcore locations 0x1000 - 0x18ff */ OFFSET (__LC_MCESAD, lowcore, mcesad);OFFSET (__LC_EXT_PARAMS2, lowcore, ext_params2);
arch/s390/kernel/crash_dump.c +1 -1
@@ -432,7 +432,7 @@ static void *get_vmcoreinfo_old(unsigned long *size)Elf64_Nhdr note;void *addr; -if (copy_oldmem_kernel (&addr, &S390_lowcore.vmcore_info,sizeof (addr))) +if (copy_oldmem_kernel (&addr, (void *)__LC_VMCORE_INFO,sizeof (addr)))return NULL ;memset (nt_name,0 ,sizeof (nt_name));if (copy_oldmem_kernel (¬e, addr,sizeof (note)))
arch/s390/kernel/os_info.c +2 -1
@@ -15,6 +15,7 @@#include <asm/checksum.h> #include <asm/lowcore.h> #include <asm/os_info.h> +#include <asm/asm-offsets.h> /* * OS info structure has to be page aligned
@@ -123,7 +124,7 @@ static void os_info_old_init(void)return ;if (!OLDMEM_BASE ) goto fail; -if (copy_oldmem_kernel (&addr, &S390_lowcore.os_info,sizeof (addr))) +if (copy_oldmem_kernel (&addr, (void *)__LC_OS_INFO,sizeof (addr))) goto fail;if (addr ==0 || addr %PAGE_SIZE ) goto fail;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 407/545 s390/zcore: fix race when reading from hardware system area
In reply to Greg Kroah-HartmanFrom: Alexander Gordeev <[email protected]>
[ Upstream commit 9ffed254d938c9e99eb7761c7f739294c84e0367 ]
Memory buffer used for reading out data from hardware system area is not protected against concurrent access.
--- drivers/s390/char/zcore.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/s390/char/zcore.c +10 -1
@@ -48,6 +48,7 @@ static struct dentry *zcore_reipl_file;static struct dentry *zcore_hsa_file;static struct ipl_parameter_block *zcore_ipl_block; +static DEFINE_MUTEX (hsa_buf_mutex);static char hsa_buf[PAGE_SIZE ]__aligned(PAGE_SIZE) ;/*
@@ -64,19 +65,24 @@ int memcpy_hsa_user(void __user *dest, unsigned long src, size_t count)if (!hsa_available)return -ENODATA ; +mutex_lock (&hsa_buf_mutex);while (count) {if (sclp_sdias_copy (hsa_buf, src /PAGE_SIZE +2 ,1 )) {TRACE ("sclp_sdias_copy() failed\n" ); +mutex_unlock (&hsa_buf_mutex);return -EIO ; } offset = src %PAGE_SIZE ; bytes =min (PAGE_SIZE - offset, count); -if (copy_to_user (dest, hsa_buf + offset, bytes)) +if (copy_to_user (dest, hsa_buf + offset, bytes)) { +mutex_unlock (&hsa_buf_mutex);return -EFAULT ; + } src += bytes; dest += bytes; count -= bytes; } +mutex_unlock (&hsa_buf_mutex);return 0 ; }
@@ -94,9 +100,11 @@ int memcpy_hsa_kernel(void *dest, unsigned long src, size_t count)if (!hsa_available)return -ENODATA ; +mutex_lock (&hsa_buf_mutex);while (count) {if (sclp_sdias_copy (hsa_buf, src /PAGE_SIZE +2 ,1 )) {TRACE ("sclp_sdias_copy() failed\n" ); +mutex_unlock (&hsa_buf_mutex);return -EIO ; } offset = src %PAGE_SIZE ;
@@ -106,6 +114,7 @@ int memcpy_hsa_kernel(void *dest, unsigned long src, size_t count) dest += bytes; count -= bytes; } +mutex_unlock (&hsa_buf_mutex);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 408/545 ASoC: fsl_easrc: use snd_pcm_format_t type for sample_format
In reply to Greg Kroah-HartmanFrom: Shengjiu Wang <[email protected]>
[ Upstream commit de27216cf2d645c2fd14e513707bdcd54e5b1de4 ]
Fix sparse warning:sound/soc/fsl/fsl_easrc.c:562:33: sparse: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl_easrc.c:563:34: sparse: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl_easrc.c:565:38: sparse: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl_easrc.c:566:39: sparse: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl_easrc.c:608:33: sparse: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl_easrc.c:609:34: sparse: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl_easrc.c:615:40: sparse: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl_easrc.c:616:41: sparse: warning: restricted snd_pcm_format_t degrades to integer
sound/soc/fsl/fsl_easrc.c:1465:51: sparse: warning: incorrect type in assignment (different base types)sound/soc/fsl/fsl_easrc.c:1465:51: sparse: expected unsigned int sample_formatsound/soc/fsl/fsl_easrc.c:1465:51: sparse: got restricted snd_pcm_format_t [usertype] formatsound/soc/fsl/fsl_easrc.c:1467:52: sparse: warning: incorrect type in assignment (different base types)sound/soc/fsl/fsl_easrc.c:1467:52: sparse: expected unsigned int sample_formatsound/soc/fsl/fsl_easrc.c:1467:52: sparse: got restricted snd_pcm_format_t [usertype] asrc_formatsound/soc/fsl/fsl_easrc.c:1470:52: sparse: warning: incorrect type in assignment (different base types)sound/soc/fsl/fsl_easrc.c:1470:52: sparse: expected unsigned int sample_formatsound/soc/fsl/fsl_easrc.c:1470:52: sparse: got restricted snd_pcm_format_t [usertype] formatsound/soc/fsl/fsl_easrc.c:1472:51: sparse: warning: incorrect type in assignment (different base types)sound/soc/fsl/fsl_easrc.c:1472:51: sparse: expected unsigned int sample_formatsound/soc/fsl/fsl_easrc.c:1472:51: sparse: got restricted snd_pcm_format_t [usertype] asrc_formatsound/soc/fsl/fsl_easrc.c:1484:41: sparse: warning: incorrect type in argument 2 (different base types)sound/soc/fsl/fsl_easrc.c:1484:41: sparse: expected restricted snd_pcm_format_t [usertype] *in_raw_formatsound/soc/fsl/fsl_easrc.c:1484:41: sparse: got unsigned int *sound/soc/fsl/fsl_easrc.c:1485:41: sparse: warning: incorrect type in argument 3 (different base types)sound/soc/fsl/fsl_easrc.c:1485:41: sparse: expected restricted snd_pcm_format_t [usertype] *out_raw_formatsound/soc/fsl/fsl_easrc.c:1485:41: sparse: got unsigned int *sound/soc/fsl/fsl_easrc.c:1937:60: sparse: warning: incorrect type in argument 3 (different base types)sound/soc/fsl/fsl_easrc.c:1937:60: sparse: expected unsigned int [usertype] *out_valuesound/soc/fsl/fsl_easrc.c:1937:60: sparse: got restricted snd_pcm_format_t *sound/soc/fsl/fsl_easrc.c:1943:49: sparse: warning: restricted snd_pcm_format_t degrades to integer
--- sound/soc/fsl/fsl_easrc.c | 9 ++++++--- sound/soc/fsl/fsl_easrc.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-)
sound/soc/fsl/fsl_easrc.c +6 -3
@@ -476,7 +476,8 @@ static int fsl_easrc_prefilter_config(struct fsl_asrc *easrc,struct fsl_asrc_pair *ctx;struct device *dev;u32 inrate, outrate, offset =0 ; -u32 in_s_rate, out_s_rate, in_s_fmt, out_s_fmt; +u32 in_s_rate, out_s_rate; +snd_pcm_format_t in_s_fmt, out_s_fmt;int ret, i;if (!easrc)
@@ -1873,6 +1874,7 @@ static int fsl_easrc_probe(struct platform_device *pdev)struct resource *res;struct device_node *np;void __iomem *regs; +u32 asrc_fmt =0 ;int ret, irq; easrc =devm_kzalloc (dev,sizeof (*easrc),GFP_KERNEL );
@@ -1939,13 +1941,14 @@ static int fsl_easrc_probe(struct platform_device *pdev)return ret; } - ret =of_property_read_u32 (np,"fsl,asrc-format" , &easrc->asrc_format); + ret =of_property_read_u32 (np,"fsl,asrc-format" , &asrc_fmt); + easrc->asrc_format = (__force snd_pcm_format_t )asrc_fmt;if (ret) {dev_err (dev,"failed to asrc format\n" );return ret; } -if (!(FSL_EASRC_FORMATS & (1ULL << easrc->asrc_format))) { +if (!(FSL_EASRC_FORMATS & (pcm_format_to_bits (easrc->asrc_format)))) {dev_warn (dev,"unsupported format, switching to S24_LE\n" ); easrc->asrc_format =SNDRV_PCM_FORMAT_S24_LE ; }
sound/soc/fsl/fsl_easrc.h +1 -1
@@ -569,7 +569,7 @@ struct fsl_easrc_io_params {unsigned int access_len;unsigned int fifo_wtmk;unsigned int sample_rate; -unsigned int sample_format; +snd_pcm_format_t sample_format;unsigned int norm_rate; };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 409/545 ASoC: qcom: q6dsp: Fix an off-by-one in q6adm_alloc_copp()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 673f58f62ca6fc98979d1cf3fe89c3ff33f29b2e ]
find_first_zero_bit() returns MAX_COPPS_PER_PORT at max here. So 'idx' should be tested with ">=" or the test can't match.
--- sound/soc/qcom/qdsp6/q6adm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/qcom/qdsp6/q6adm.c +1 -1
@@ -217,7 +217,7 @@ static struct q6copp *q6adm_alloc_copp(struct q6adm *adm, int port_idx) idx =find_first_zero_bit (&adm->copp_bitmap[port_idx],MAX_COPPS_PER_PORT ); -if (idx >MAX_COPPS_PER_PORT ) +if (idx >=MAX_COPPS_PER_PORT )return ERR_PTR (-EBUSY ); c =kzalloc (sizeof (*c),GFP_ATOMIC );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 410/545 fuse: Remove the control interface for virtio-fs
In reply to Greg Kroah-HartmanFrom: Xie Yongji <[email protected]>
[ Upstream commit c64797809a64c73497082aa05e401a062ec1af34 ]
The commit 15c8e72e88e0 ("fuse: allow skipping control interface and forced unmount") tries to remove the control interface for virtio-fs since it does not support aborting requests which are being processed. But it doesn't work now.
This patch fixes it by skipping creating the control interface if fuse_conn->no_control is set.
--- fs/fuse/control.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/fuse/control.c +2 -2
@@ -275,7 +275,7 @@ int fuse_ctl_add_conn(struct fuse_conn *fc)struct dentry *parent;char name[32 ]; -if (!fuse_control_sb) +if (!fuse_control_sb || fc->no_control)return 0 ; parent = fuse_control_sb->s_root;
@@ -313,7 +313,7 @@ void fuse_ctl_remove_conn(struct fuse_conn *fc) {int i; -if (!fuse_control_sb) +if (!fuse_control_sb || fc->no_control)return ;for (i = fc->ctl_ndents -1 ; i >=0 ; i--) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 411/545 ASoC: audio-graph-card: Add of_node_put() in fail path
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 65fb8e2ef3531a6e950060fca6e551c923fb0f0e ]
In asoc_simple_parse_dai(), we should call of_node_put() for the reference returned by of_graph_get_port_parent() in fail path.
--- sound/soc/generic/audio-graph-card.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/generic/audio-graph-card.c +3 -1
@@ -149,8 +149,10 @@ static int asoc_simple_parse_dai(struct device_node *ep,* if he unbinded CPU or Codec. */ ret =snd_soc_get_dai_name (&args, &dlc->dai_name); -if (ret <0 ) +if (ret <0 ) { +of_node_put (node);return ret; + } dlc->of_node = node;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 412/545 watchdog: armada_37xx_wdt: check the return value of devm_ioremap() in armada_37xx_wdt_probe()
In reply to Greg Kroah-HartmanFrom: William Dean <[email protected]>
[ Upstream commit 2d27e52841092e5831dd41f313028c668d816eb0 ]
The function devm_ioremap() in armada_37xx_wdt_probe() can fail, so its return value should be checked.
--- drivers/watchdog/armada_37xx_wdt.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/watchdog/armada_37xx_wdt.c +2 -0
@@ -274,6 +274,8 @@ static int armada_37xx_wdt_probe(struct platform_device *pdev)if (!res)return -ENODEV ; dev->reg =devm_ioremap (&pdev->dev, res->start,resource_size (res)); +if (!dev->reg) +return -ENOMEM ;/* init clock */ dev->clk =devm_clk_get (&pdev->dev,NULL );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 413/545 video: fbdev: amba-clcd: Fix refcount leak bugs
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 26c2b7d9fac42eb8317f3ceefa4c1a9a9170ca69 ]
In clcdfb_of_init_display(), we should call of_node_put() for the references returned by of_graph_get_next_endpoint() and of_graph_get_remote_port_parent() which have increased the refcount.
Besides, we should call of_node_put() both in fail path or when the references are not used anymore.
--- drivers/video/fbdev/amba-clcd.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/video/fbdev/amba-clcd.c +18 -6
@@ -711,16 +711,18 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)return -ENODEV ; panel =of_graph_get_remote_port_parent (endpoint); -if (!panel) -return -ENODEV ; +if (!panel) { + err = -ENODEV ; + goto out_endpoint_put; + } err =clcdfb_of_get_backlight (&fb->dev->dev, fb->panel);if (err) -return err; + goto out_panel_put; err =clcdfb_of_get_mode (&fb->dev->dev, panel, fb->panel);if (err) -return err; + goto out_panel_put; err =of_property_read_u32 (fb->dev->dev.of_node,"max-memory-bandwidth" , &max_bandwidth);
@@ -749,11 +751,21 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)if (of_property_read_u32_array (endpoint,"arm,pl11x,tft-r0g0b0-pads" , - tft_r0b0g0,ARRAY_SIZE (tft_r0b0g0)) !=0 ) -return -ENOENT ; + tft_r0b0g0,ARRAY_SIZE (tft_r0b0g0)) !=0 ) { + err = -ENOENT ; + goto out_panel_put; + } + +of_node_put (panel); +of_node_put (endpoint);return clcdfb_of_init_tft_panel (fb, tft_r0b0g0[0 ], tft_r0b0g0[1 ], tft_r0b0g0[2 ]); +out_panel_put: +of_node_put (panel); +out_endpoint_put: +of_node_put (endpoint); +return err; }static int clcdfb_of_vram_setup (struct clcd_fb *fb)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 414/545 video: fbdev: sis: fix typos in SiS_GetModeID()
In reply to Greg Kroah-HartmanFrom: Rustam Subkhankulov <[email protected]>
[ Upstream commit 3eb8fccc244bfb41a7961969e4db280d44911226 ]
The second operand of a '&&' operator has no impact on expression result for cases 400 and 512 in SiS_GetModeID().
Judging by the logic and the names of the variables, in both cases a typo was made.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/video/fbdev/sis/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/sis/init.c +2 -2
@@ -355,12 +355,12 @@ SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, }break ;case 400 : -if ((!(VBFlags &CRT1_LCDA )) || ((LCDwidth >=800 ) && (LCDwidth >=600 ))) { +if ((!(VBFlags &CRT1_LCDA )) || ((LCDwidth >=800 ) && (LCDheight >=600 ))) {if (VDisplay ==300 ) ModeIndex = ModeIndex_400x300[Depth]; }break ;case 512 : -if ((!(VBFlags &CRT1_LCDA )) || ((LCDwidth >=1024 ) && (LCDwidth >=768 ))) { +if ((!(VBFlags &CRT1_LCDA )) || ((LCDwidth >=1024 ) && (LCDheight >=768 ))) {if (VDisplay ==384 ) ModeIndex = ModeIndex_512x384[Depth]; }break ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 415/545 ASoC: mchp-spdifrx: disable end of block interrupt on failures
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 768ac4f12ca0fda935f58eb8c5120e9d795bc6e3 ]
Disable end of block interrupt in case of wait for completion timeout or errors to undo previously enable operation (done in mchp_spdifrx_isr_blockend_en()). Otherwise we can end up with an unbalanced reference counter for this interrupt.
--- sound/soc/atmel/mchp-spdifrx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/soc/atmel/mchp-spdifrx.c +6 -3
@@ -288,15 +288,17 @@ static void mchp_spdifrx_isr_blockend_en(struct mchp_spdifrx_dev *dev)spin_unlock_irqrestore (&dev->blockend_lock, flags); } -/* called from atomic context only */ +/* called from atomic/non-atomic context */ static void mchp_spdifrx_isr_blockend_dis (struct mchp_spdifrx_dev *dev) { -spin_lock (&dev->blockend_lock); +unsigned long flags; + +spin_lock_irqsave (&dev->blockend_lock, flags); dev->blockend_refcount--;/* don't enable BLOCKEND interrupt if it's already enabled */ if (dev->blockend_refcount ==0 )regmap_write (dev->regmap,SPDIFRX_IDR ,SPDIFRX_IR_BLOCKEND ); -spin_unlock (&dev->blockend_lock); +spin_unlock_irqrestore (&dev->blockend_lock, flags); }static irqreturn_t mchp_spdif_interrupt (int irq,void *dev_id)
@@ -575,6 +577,7 @@ static int mchp_spdifrx_subcode_ch_get(struct mchp_spdifrx_dev *dev,if (ret <=0 ) {dev_dbg (dev->dev,"user data for channel %d timeout\n" , channel); +mchp_spdifrx_isr_blockend_dis (dev);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 416/545 powerpc/32: Do not allow selection of e5500 or e6500 CPUs on PPC32
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
[ Upstream commit 9be013b2a9ecb29b5168e4b9db0e48ed53acf37c ]
Commit 0e00a8c9fd92 ("powerpc: Allow CPU selection also on PPC32") enlarged the CPU selection logic to PPC32 by removing depend to PPC64, and failed to restrict that depend to E5500_CPU and E6500_CPU. Fortunately that got unnoticed because -mcpu=8540 will override the -mcpu=e500mc64 or -mpcu=e6500 as they are ealier, but that's fragile and may no be right in the future.
Add back the depend PPC64 on E5500_CPU and E6500_CPU.
--- arch/powerpc/platforms/Kconfig.cputype | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/Kconfig.cputype +2 -2
@@ -152,11 +152,11 @@ config POWER9_CPU config E5500_CPU bool "Freescale e5500" - depends on E500 + depends on PPC64 && E500 config E6500_CPU bool "Freescale e6500" - depends on E500 + depends on PPC64 && E500 config 860_CPU bool "8xx family"
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 417/545 powerpc/pci: Prefer PCI domain assignment via DT linux,pci-domain and alias
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
[ Upstream commit 0fe1e96fef0a5c53b4c0d1500d356f3906000f81 ]
Other Linux architectures use DT property 'linux,pci-domain' for specifying fixed PCI domain of PCI controller specified in Device-Tree.
And lot of Freescale powerpc boards have defined numbered pci alias in Device-Tree for every PCIe controller which number specify preferred PCI domain.
So prefer usage of DT property 'linux,pci-domain' (via function of_get_pci_domain_nr()) and DT pci alias (via function of_alias_get_id()) on powerpc architecture for assigning PCI domain to PCI controller.
--- arch/powerpc/kernel/pci-common.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
arch/powerpc/kernel/pci-common.c +19 -8
@@ -73,16 +73,30 @@ void set_pci_dma_ops(const struct dma_map_ops *dma_ops)static int get_phb_number (struct device_node *dn) {int ret, phb_id =-1 ; -u32 prop_32;u64 prop;/* * Try fixed PHB numbering first, by checking archs and reading -* the respective device-tree properties. Firstly, try powernv by -* reading "ibm,opal-phbid", only present in OPAL environment. +* the respective device-tree properties. Firstly, try reading +* standard "linux,pci-domain", then try reading "ibm,opal-phbid" +* (only present in powernv OPAL environment), then try device-tree +* alias and as the last try to use lower bits of "reg" property. */ - ret =of_property_read_u64 (dn,"ibm,opal-phbid" , &prop); + ret =of_get_pci_domain_nr (dn); +if (ret >=0 ) { + prop = ret; + ret =0 ; + } +if (ret) + ret =of_property_read_u64 (dn,"ibm,opal-phbid" , &prop); +if (ret) + ret =of_alias_get_id (dn,"pci" ); +if (ret >=0 ) { + prop = ret; + ret =0 ; + }if (ret) { +u32 prop_32; ret =of_property_read_u32_index (dn,"reg" ,1 , &prop_32); prop = prop_32; }
@@ -94,10 +108,7 @@ static int get_phb_number(struct device_node *dn)if ((phb_id >=0 ) && !test_and_set_bit (phb_id, phb_bitmap))return phb_id; -/* -* If not pseries nor powernv, or if fixed PHB numbering tried to add -* the same PHB number twice, then fallback to dynamic PHB numbering. -*/ +/* If everything fails then fallback to dynamic PHB numbering. */ phb_id =find_first_zero_bit (phb_bitmap,MAX_PHBS );BUG_ON (phb_id >=MAX_PHBS );set_bit (phb_id, phb_bitmap);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 418/545 f2fs: dont set GC_FAILURE_PIN for background GC
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit 642c0969916eaa4878cb74f36752108e590b0389 ]
So that it can reduce the possibility that file be unpinned forcely by foreground GC due to .i_gc_failures[GC_FAILURE_PIN] exceeds threshold.
--- fs/f2fs/gc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/gc.c +2 -1
@@ -1158,7 +1158,8 @@ static int move_data_block(struct inode *inode, block_t bidx, }if (f2fs_is_pinned_file (inode)) { -f2fs_pin_file_control (inode, true); +if (gc_type ==FG_GC ) +f2fs_pin_file_control (inode, true); err = -EAGAIN ; goto out; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 419/545 f2fs: write checkpoint during FG_GC
In reply to Greg Kroah-HartmanFrom: Byungki Lee <[email protected]>
[ Upstream commit a9163b947ae8f7af7cb8d63606cd87b9facbfe74 ]
If there's not enough free sections each of which consistis of large segments, we can hit no free section for upcoming section allocation. Let's reclaim some prefree segments by writing checkpoints.
--- fs/f2fs/gc.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-)
fs/f2fs/gc.c +23 -15
@@ -1741,23 +1741,31 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,if (sync) goto stop; -if (has_not_enough_free_secs (sbi, sec_freed,0 )) { -if (skipped_round <=MAX_SKIP_GC_COUNT || - skipped_round *2 < round) { - segno =NULL_SEGNO ; - goto gc_more; - } +if (!has_not_enough_free_secs (sbi, sec_freed,0 )) + goto stop; -if (first_skipped < last_skipped && - (last_skipped - first_skipped) > - sbi->skipped_gc_rwsem) { -f2fs_drop_inmem_pages_all (sbi, true); - segno =NULL_SEGNO ; - goto gc_more; - } -if (gc_type ==FG_GC && !is_sbi_flag_set (sbi,SBI_CP_DISABLED )) +if (skipped_round <=MAX_SKIP_GC_COUNT || skipped_round *2 < round) { + +/* Write checkpoint to reclaim prefree segments */ +if (free_sections (sbi) <NR_CURSEG_PERSIST_TYPE && +prefree_segments (sbi) && + !is_sbi_flag_set (sbi,SBI_CP_DISABLED )) { ret =f2fs_write_checkpoint (sbi, &cpc); - } +if (ret) + goto stop; + } + segno =NULL_SEGNO ; + goto gc_more; + } +if (first_skipped < last_skipped && + (last_skipped - first_skipped) > + sbi->skipped_gc_rwsem) { +f2fs_drop_inmem_pages_all (sbi, true); + segno =NULL_SEGNO ; + goto gc_more; + } +if (gc_type ==FG_GC && !is_sbi_flag_set (sbi,SBI_CP_DISABLED )) + ret =f2fs_write_checkpoint (sbi, &cpc); stop:SIT_I (sbi)->last_victim[ALLOC_NEXT ] =0 ;SIT_I (sbi)->last_victim[FLUSH_DEVICE ] = init_segno;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 420/545 f2fs: fix to remove F2FS_COMPR_FL and tag F2FS_NOCOMP_FL at the same time
In reply to Greg Kroah-HartmanFrom: Chao Liu <[email protected]>
[ Upstream commit 8ee236dcaa690d09ca612622e8bc8d09c302021d ]
If the inode has the compress flag, it will fail to use 'chattr -c +m' to remove its compress flag and tag no compress flag. However, the same command will be successful when executed again, as shown below:
$ touch foo.txt $ chattr +c foo.txt $ chattr -c +m foo.txt chattr: Invalid argument while setting flags on foo.txt $ chattr -c +m foo.txt $ f2fs_io getflags foo.txt get a flag on foo.txt ret=0, flags=nocompression,inline_data
Fix this by removing some checks in f2fs_setflags_common() that do not affect the original logic. I go through all the possible scenarios, and the results are as follows. Bold is the only thing that has changed.
+---------------+-----------+-----------+----------+ | | file flags | + command +-----------+-----------+----------+ | | no flag | compr | nocompr | +---------------+-----------+-----------+----------+ | chattr +c | compr | compr | -EINVAL | | chattr -c | no flag | no flag | nocompr | | chattr +m | nocompr | -EINVAL | nocompr | | chattr -m | no flag | compr | no flag | | chattr +c +m | -EINVAL | -EINVAL | -EINVAL | | chattr +c -m | compr | compr | compr | | chattr -c +m | nocompr | *nocompr* | nocompr | | chattr -c -m | no flag | no flag | no flag | +---------------+-----------+-----------+----------+
--- fs/f2fs/file.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
fs/f2fs/file.c +1 -8
@@ -1844,10 +1844,7 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)if (masked_flags &F2FS_COMPR_FL ) {if (!f2fs_disable_compressed_file (inode))return -EINVAL ; - } -if (iflags &F2FS_NOCOMP_FL ) -return -EINVAL ; -if (iflags &F2FS_COMPR_FL ) { + }else {if (!f2fs_may_compress (inode))return -EINVAL ;if (S_ISREG (inode->i_mode) && inode->i_size)
@@ -1856,10 +1853,6 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)set_compress_context (inode); } } -if ((iflags ^ masked_flags) &F2FS_NOCOMP_FL ) { -if (masked_flags &F2FS_COMPR_FL ) -return -EINVAL ; - } fi->i_flags = iflags | (fi->i_flags & ~mask); f2fs_bug_on(F2FS_I_SB(inode), (fi->i_flags & F2FS_COMPR_FL) &&
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 421/545 powerpc/spufs: Fix refcount leak in spufs_init_isolated_loader
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 6ac059dacffa8ab2f7798f20e4bd3333890c541c ]
of_find_node_by_path() returns remote device nodepointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak.
--- arch/powerpc/platforms/cell/spufs/inode.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/platforms/cell/spufs/inode.c +1 -0
@@ -664,6 +664,7 @@ spufs_init_isolated_loader(void)return ; loader =of_get_property (dn,"loader" , &size); +of_node_put (dn);if (!loader)return ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 422/545 powerpc/xive: Fix refcount leak in xive_get_max_prio
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 255b650cbec6849443ce2e0cdd187fd5e61c218c ]
of_find_node_by_path() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak.
--- arch/powerpc/sysdev/xive/spapr.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/sysdev/xive/spapr.c +1 -0
@@ -710,6 +710,7 @@ static bool xive_get_max_prio(u8 *max_prio) } reg =of_get_property (rootdn,"ibm,plat-res-int-priorities" , &len); +of_node_put (rootdn);if (!reg) {pr_err ("Failed to read 'ibm,plat-res-int-priorities' property\n" );return false;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 423/545 powerpc/cell/axon_msi: Fix refcount leak in setup_msi_msg_address
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit df5d4b616ee76abc97e5bd348e22659c2b095b1c ]
of_get_next_parent() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() in the error path to avoid refcount leak.
--- arch/powerpc/platforms/cell/axon_msi.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/platforms/cell/axon_msi.c +1 -0
@@ -226,6 +226,7 @@ static int setup_msi_msg_address(struct pci_dev *dev, struct msi_msg *msg)if (!prop) {dev_dbg (&dev->dev,"axon_msi: no msi-address-(32|64) properties found\n" ); +of_node_put (dn);return -ENOENT ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 424/545 perf symbol: Fail to read phdr workaround
In reply to Greg Kroah-HartmanFrom: Ian Rogers <[email protected]>
[ Upstream commit 6d518ac7be6223811ab947897273b1bbef846180 ]
The perf jvmti agent doesn't create program headers, in this case fallback on section headers as happened previously.
Committer notes:
To test this, from a public post by Ian:
1) download a Java workload dacapo-9.12-MR1-bach.jar from
https://sourceforge.net/projects/dacapobench/
2) build perf such as "make -C tools/perf O=/tmp/perf NO_LIBBFD=1" it should detect Java and create /tmp/perf/libperf-jvmti.so
3) run perf with the jvmti agent:
perf record -k 1 java -agentpath:/tmp/perf/libperf-jvmti.so -jar dacapo-9.12-MR1-bach.jar -n 10 fop
4) run perf inject:
perf inject -i perf.data -o perf-injected.data -j
5) run perf report
perf report -i perf-injected.data | grep org.apache.fop
With this patch reverted I see lots of symbols like:
0.00% java jitted-388040-4656.so [.] org.apache.fop.fo.FObj.bind(org.apache.fop.fo.PropertyList)
With the patch (2d86612aacb7805f ("perf symbol: Correct address for bss symbols")) I see lots of:
dso__load_sym_internal: failed to find program header for symbol:
Lorg/apache/fop/fo/FObj;bind(Lorg/apache/fop/fo/PropertyList;)V
st_value: 0x40
--- tools/perf/util/symbol-elf.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
tools/perf/util/symbol-elf.c +20 -7
@@ -1249,16 +1249,29 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,if (elf_read_program_header (syms_ss->elf, (u64 )sym.st_value, &phdr)) { -pr_warning ("%s: failed to find program header for " +pr_debug4 ("%s: failed to find program header for " "symbol: %s st_value: %#" PRIx64"\n" , __func__, elf_name, (u64 )sym.st_value); -continue ; +pr_debug4 ("%s: adjusting symbol: st_value: %#" PRIx64" " +"sh_addr: %#" PRIx64" sh_offset: %#" PRIx64"\n" , + __func__, (u64 )sym.st_value, (u64 )shdr.sh_addr, + (u64 )shdr.sh_offset); +/* +* Fail to find program header, let's rollback +* to use shdr.sh_addr and shdr.sh_offset to +* calibrate symbol's file address, though this +* is not necessary for normal C ELF file, we +* still need to handle java JIT symbols in this +* case. +*/ + sym.st_value -= shdr.sh_addr - shdr.sh_offset; + }else { +pr_debug4 ("%s: adjusting symbol: st_value: %#" PRIx64" " +"p_vaddr: %#" PRIx64" p_offset: %#" PRIx64"\n" , + __func__, (u64 )sym.st_value, (u64 )phdr.p_vaddr, + (u64 )phdr.p_offset); + sym.st_value -= phdr.p_vaddr - phdr.p_offset; } -pr_debug4 ("%s: adjusting symbol: st_value: %#" PRIx64" " -"p_vaddr: %#" PRIx64" p_offset: %#" PRIx64"\n" , - __func__, (u64 )sym.st_value, (u64 )phdr.p_vaddr, - (u64 )phdr.p_offset); - sym.st_value -= phdr.p_vaddr - phdr.p_offset; } demangled =demangle_sym (dso, kmodule, elf_name);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 425/545 kprobes: Forbid probing on trampoline and BPF code areas
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit 28f6c37a2910f565b4f5960df52b2eccae28c891 ]
kernel_text_address() treats ftrace_trampoline, kprobe_insn_slot and bpf_text_address as valid kprobe addresses - which is not ideal.
These text areas are removable and changeable without any notification to kprobes, and probing on them can trigger unexpected behavior:
https://lkml.org/lkml/2022/7/26/1148
Considering that jump_label and static_call text are already forbiden to probe, kernel_text_address() should be replaced with core_kernel_text() and is_module_text_address() to check other text areas which are unsafe to kprobe.
[ mingo: Rewrote the changelog. ]
--- kernel/kprobes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/kprobes.c +2 -1
@@ -1640,7 +1640,8 @@ static int check_kprobe_address_safe(struct kprobe *p,preempt_disable ();/* Ensure it is not in reserved area nor out of text */ - if (!kernel_text_address((unsigned long) p->addr) || + if (!(core_kernel_text((unsigned long) p->addr) || + is_module_text_address((unsigned long) p->addr)) || within_kprobe_blacklist((unsigned long) p->addr) || jump_label_text_reserved(p->addr, p->addr) || static_call_text_reserved(p->addr, p->addr) ||
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 426/545 powerpc/pci: Fix PHB numbering when using opal-phbid
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
[ Upstream commit f4b39e88b42d13366b831270306326b5c20971ca ]
The recent change to the PHB numbering logic has a logic error in the handling of "ibm,opal-phbid".
When an "ibm,opal-phbid" property is present, &prop is written to and ret is set to zero.
The following call to of_alias_get_id() is skipped because ret == 0.
But then the if (ret >= 0) is true, and the body of that if statement sets prop = ret which throws away the value that was just read from "ibm,opal-phbid".
Fix the logic by only doing the ret >= 0 check in the of_alias_get_id() case.
--- arch/powerpc/kernel/pci-common.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/powerpc/kernel/pci-common.c +6 -4
@@ -89,11 +89,13 @@ static int get_phb_number(struct device_node *dn) }if (ret) ret =of_property_read_u64 (dn,"ibm,opal-phbid" , &prop); -if (ret) + +if (ret) { ret =of_alias_get_id (dn,"pci" ); -if (ret >=0 ) { - prop = ret; - ret =0 ; +if (ret >=0 ) { + prop = ret; + ret =0 ; + } }if (ret) {u32 prop_32;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 427/545 genelf: Use HAVE_LIBCRYPTO_SUPPORT, not the never defined HAVE_LIBCRYPTO
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 91cea6be90e436c55cde8770a15e4dac9d3032d0 ]
When genelf was introduced it tested for HAVE_LIBCRYPTO not HAVE_LIBCRYPTO_SUPPORT, which is the define the feature test for openssl defines, fix it.
This also adds disables the deprecation warning, someone has to fix this to build with openssl 3.0 before the warning becomes a hard error.
--- tools/perf/util/genelf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/util/genelf.c +5 -1
@@ -30,7 +30,11 @@#define BUILD_ID_URANDOM /* different uuid for each run */ -#ifdef HAVE_LIBCRYPTO +// FIXME, remove this and fix the deprecation warnings before its removed and +// We'll break for good here... +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + +#ifdef HAVE_LIBCRYPTO_SUPPORT #define BUILD_ID_MD5 #undef BUILD_ID_SHA/* does not seem to work well when linked with Java */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 428/545 scripts/faddr2line: Fix vmlinux detection on arm64
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit b6a5068854cfe372da7dee3224dcf023ed5b00cb ]
Since commit dcea997beed6 ("faddr2line: Fix overlapping text section failures, the sequel"), faddr2line is completely broken on arm64.
For some reason, on arm64, the vmlinux ELF object file type is ET_DYN rather than ET_EXEC. Check for both when determining whether the object is vmlinux.
Modules and vmlinux.o have type ET_REL on all arches.
--- scripts/faddr2line | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/faddr2line +3 -1
@@ -112,7 +112,9 @@ __faddr2line() { # section offsets. local file_type=$(${READELF} --file-header $objfile | ${AWK} '$1 == "Type:" { print $2; exit }') - [[ $file_type = "EXEC" ]] && is_vmlinux=1 + if [[ $file_type = "EXEC" ]] || [[ $file_type == "DYN" ]]; then + is_vmlinux=1 + fi # Go through each of the object's symbols which match the func name. # In rare cases there might be duplicates, in which case we print all
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 429/545 sched/deadline: Merge dl_task_can_attach() and dl_cpu_busy()
In reply to Greg Kroah-HartmanFrom: Dietmar Eggemann <[email protected]>
[ Upstream commit 772b6539fdda31462cc08368e78df60b31a58bab ]
Both functions are doing almost the same, that is checking if admission control is still respected.
With exclusive cpusets, dl_task_can_attach() checks if the destination cpuset (i.e. its root domain) has enough CPU capacity to accommodate the task.dl_cpu_busy() checks if there is enough CPU capacity in the cpuset in case the CPU is hot-plugged out.
dl_task_can_attach() is used to check if a task can be admitted while dl_cpu_busy() is used to check if a CPU can be hotplugged out.
Make dl_cpu_busy() able to deal with a task and use it instead of dl_task_can_attach() in task_can_attach().
--- kernel/sched/core.c | 13 +++++++---- kernel/sched/deadline.c | 52 +++++++++++------------------------------ kernel/sched/sched.h | 3 +-- 3 files changed, 24 insertions(+), 44 deletions(-)
kernel/sched/core.c +9 -4
@@ -6605,8 +6605,11 @@ int task_can_attach(struct task_struct *p, }if (dl_task (p) && !cpumask_intersects (task_rq (p)->rd->span, - cs_cpus_allowed)) - ret =dl_task_can_attach (p, cs_cpus_allowed); + cs_cpus_allowed)) { +int cpu =cpumask_any_and (cpu_active_mask, cs_cpus_allowed); + + ret =dl_cpu_busy (cpu, p); + } out:return ret;
@@ -6865,8 +6868,10 @@ static void cpuset_cpu_active(void)static int cpuset_cpu_inactive (unsigned int cpu) {if (!cpuhp_tasks_frozen) { -if (dl_cpu_busy (cpu)) -return -EBUSY ; +int ret =dl_cpu_busy (cpu,NULL ); + +if (ret) +return ret;cpuset_update_active_cpus (); }else { num_cpus_frozen++;
kernel/sched/deadline.c +14 -38
73 lines not on this page · raw message
kernel/sched/sched.h +1 -2
@@ -347,9 +347,8 @@ extern void __setparam_dl(struct task_struct *p, const struct sched_attr *attr);extern void __getparam_dl (struct task_struct *p,struct sched_attr *attr);extern bool __checkparam_dl (const struct sched_attr *attr);extern bool dl_param_changed (struct task_struct *p,const struct sched_attr *attr); -extern int dl_task_can_attach (struct task_struct *p,const struct cpumask *cs_cpus_allowed);extern int dl_cpuset_cpumask_can_shrink (const struct cpumask *cur,const struct cpumask *trial); -extern bool dl_cpu_busy (unsigned int cpu); +extern int dl_cpu_busy (int cpu,struct task_struct *p);#ifdef CONFIG_CGROUP_SCHED
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 430/545 sched, cpuset: Fix dl_cpu_busy() panic due to empty cs->cpus_allowed
In reply to Greg Kroah-HartmanFrom: Waiman Long <[email protected]>
[ Upstream commit b6e8d40d43ae4dec00c8fea2593eeea3114b8f44 ]
With cgroup v2, the cpuset's cpus_allowed mask can be empty indicating that the cpuset will just use the effective CPUs of its parent. So cpuset_can_attach() can call task_can_attach() with an empty mask. This can lead to cpumask_any_and() returns nr_cpu_ids causing the call to dl_bw_of() to crash due to percpu value access of an out of bound CPU value. For example:
[80468.182258] BUG: unable to handle page fault for address: ffffffff8b6648b0 : [80468.191019] RIP: 0010:dl_cpu_busy+0x30/0x2b0 : [80468.207946] Call Trace: [80468.208947] cpuset_can_attach+0xa0/0x140 [80468.209953] cgroup_migrate_execute+0x8c/0x490 [80468.210931] cgroup_update_dfl_csses+0x254/0x270 [80468.211898] cgroup_subtree_control_write+0x322/0x400 [80468.212854] kernfs_fop_write_iter+0x11c/0x1b0 [80468.213777] new_sync_write+0x11f/0x1b0 [80468.214689] vfs_write+0x1eb/0x280 [80468.215592] ksys_write+0x5f/0xe0 [80468.216463] do_syscall_64+0x5c/0x80 [80468.224287] entry_SYSCALL_64_after_hwframe+0x44/0xae
Fix that by using effective_cpus instead. For cgroup v1, effective_cpus is the same as cpus_allowed. For v2, effective_cpus is the real cpumask to be used by tasks within the cpuset anyway.
Also update task_can_attach()'s 2nd argument name to cs_effective_cpus to reflect the change. In addition, a check is added to task_can_attach() to guard against the possibility that cpumask_any_and() may return a value >= nr_cpu_ids.
--- include/linux/sched.h | 2 +- kernel/cgroup/cpuset.c | 2 +- kernel/sched/core.c | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-)
include/linux/sched.h +1 -1
@@ -1658,7 +1658,7 @@ current_restore_flags(unsigned long orig_flags, unsigned long flags) }extern int cpuset_cpumask_can_shrink (const struct cpumask *cur,const struct cpumask *trial); -extern int task_can_attach (struct task_struct *p,const struct cpumask *cs_cpus_allowed); +extern int task_can_attach (struct task_struct *p,const struct cpumask *cs_effective_cpus);#ifdef CONFIG_SMP extern void do_set_cpus_allowed (struct task_struct *p,const struct cpumask *new_mask);extern int set_cpus_allowed_ptr (struct task_struct *p,const struct cpumask *new_mask);
kernel/cgroup/cpuset.c +1 -1
@@ -2162,7 +2162,7 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) goto out_unlock;cgroup_taskset_for_each (task, css, tset) { - ret =task_can_attach (task, cs->cpus_allowed); + ret =task_can_attach (task, cs->effective_cpus);if (ret) goto out_unlock; ret =security_task_setscheduler (task);
kernel/sched/core.c +5 -3
@@ -6586,7 +6586,7 @@ int cpuset_cpumask_can_shrink(const struct cpumask *cur, }int task_can_attach (struct task_struct *p, -const struct cpumask *cs_cpus_allowed) +const struct cpumask *cs_effective_cpus) {int ret =0 ;
@@ -6605,9 +6605,11 @@ int task_can_attach(struct task_struct *p, }if (dl_task (p) && !cpumask_intersects (task_rq (p)->rd->span, - cs_cpus_allowed)) { -int cpu =cpumask_any_and (cpu_active_mask, cs_cpus_allowed); + cs_effective_cpus)) { +int cpu =cpumask_any_and (cpu_active_mask, cs_effective_cpus); +if (unlikely (cpu >= nr_cpu_ids)) +return -EINVAL ; ret =dl_cpu_busy (cpu, p); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 431/545 x86/numa: Use cpumask_available instead of hardcoded NULL check
In reply to Greg Kroah-HartmanFrom: Siddh Raman Pant <[email protected]>
[ Upstream commit 625395c4a0f4775e0fe00f616888d2e6c1ba49db ]
GCC-12 started triggering a new warning:
arch/x86/mm/numa.c: In function ‘cpumask_of_node’:
arch/x86/mm/numa.c:916:39: warning: the comparison will always evaluate as ‘false’ for the address of ‘node_to_cpumask_map’ will never be NULL [-Waddress]
916 | if (node_to_cpumask_map[node] == NULL) {
| ^~node_to_cpumask_map is of type cpumask_var_t[].
When CONFIG_CPUMASK_OFFSTACK is set, cpumask_var_t is typedef'd to a pointer for dynamic allocation, else to an array of one element. The "wicked game" can be checked on line 700 of include/linux/cpumask.h.
The original code in debug_cpumask_set_cpu() and cpumask_of_node() were probably written by the original authors with CONFIG_CPUMASK_OFFSTACK=y (i.e. dynamic allocation) in mind, checking if the cpumask was available via a direct NULL check.
When CONFIG_CPUMASK_OFFSTACK is not set, GCC gives the above warning while compiling the kernel.
Fix that by using cpumask_available(), which does the NULL check when CONFIG_CPUMASK_OFFSTACK is set, otherwise returns true. Use it wherever such checks are made.
Conditional definitions of cpumask_available() can be found along with the definition of cpumask_var_t. Check the cpumask.h reference mentioned above.
--- arch/x86/mm/numa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/mm/numa.c +2 -2
@@ -861,7 +861,7 @@ void debug_cpumask_set_cpu(int cpu, int node, bool enable)return ; } mask = node_to_cpumask_map[node]; -if (!mask) { +if (!cpumask_available (mask)) {pr_err ("node_to_cpumask_map[%i] NULL\n" , node);dump_stack ();return ;
@@ -907,7 +907,7 @@ const struct cpumask *cpumask_of_node(int node)dump_stack ();return cpu_none_mask; } -if (node_to_cpumask_map[node] ==NULL ) { +if (!cpumask_available (node_to_cpumask_map[node])) {printk (KERN_WARNING "cpumask_of_node(%d): no node_to_cpumask_map!\n" , node);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 432/545 video: fbdev: arkfb: Fix a divide-by-zero bug in ark_set_pixclock()
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 2f1c4523f7a3aaabe7e53d3ebd378292947e95c8 ]
Since the user can control the arguments of the ioctl() from the user
space, under special arguments that may result in a divide-by-zero bug
in:
drivers/video/fbdev/arkfb.c:784: ark_set_pixclock(info, (hdiv * info->var.pixclock) / hmul);
with hdiv=1, pixclock=1 and hmul=2 you end up with (1*1)/2 = (int) 0.
and then in:
drivers/video/fbdev/arkfb.c:504: rv = dac_set_freq(par->dac, 0, 1000000000 / pixclock);
we'll get a division-by-zero.
The following log can reveal it:
divide error: 0000 [#1] PREEMPT SMP KASAN PTI
RIP: 0010:ark_set_pixclock drivers/video/fbdev/arkfb.c:504 [inline] RIP: 0010:arkfb_set_par+0x10fc/0x24c0 drivers/video/fbdev/arkfb.c:784 Call Trace: fb_set_var+0x604/0xeb0 drivers/video/fbdev/core/fbmem.c:1034 do_fb_ioctl+0x234/0x670 drivers/video/fbdev/core/fbmem.c:1110 fb_ioctl+0xdd/0x130 drivers/video/fbdev/core/fbmem.c:1189
Fix this by checking the argument of ark_set_pixclock() first.
--- drivers/video/fbdev/arkfb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/video/fbdev/arkfb.c +6 -1
@@ -778,7 +778,12 @@ static int arkfb_set_par(struct fb_info *info)return -EINVAL ; } -ark_set_pixclock (info, (hdiv * info->var.pixclock) / hmul); + value = (hdiv * info->var.pixclock) / hmul; +if (!value) { +fb_dbg (info,"invalid pixclock\n" ); + value =1 ; + } +ark_set_pixclock (info, value); svga_set_timings(par->state.vgabase, &ark_timing_regs, &(info->var), hmul, hdiv, (info->var.vmode & FB_VMODE_DOUBLE) ? 2 : 1, (info->var.vmode & FB_VMODE_INTERLACED) ? 2 : 1,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 433/545 tools/thermal: Fix possible path truncations
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 6c58cf40e3a1d2f47c09d3489857e9476316788a ]
A build with -D_FORTIFY_SOURCE=2 enabled will produce the following warnings:
sysfs.c:63:30: warning: '%s' directive output may be truncated writing up to 255 bytes into a region of size between 0 and 255 [-Wformat-truncation=]
snprintf(filepath, 256, "%s/%s", path, filename);
^~Bump up the buffer to PATH_MAX which is the limit and account for all of the possible NUL and separators that could lead to exceeding the allocated buffer sizes.
--- tools/thermal/tmon/sysfs.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
tools/thermal/tmon/sysfs.c +13 -11
@@ -13,6 +13,7 @@#include <stdint.h> #include <dirent.h> #include <libintl.h> +#include <limits.h> #include <ctype.h> #include <time.h> #include <syslog.h>
@@ -33,9 +34,9 @@ int sysfs_set_ulong(char *path, char *filename, unsigned long val) {FILE *fd;int ret =-1 ; -char filepath[256 ]; +char filepath[PATH_MAX +2 ];/* NUL and '/' */ -snprintf (filepath,256 ,"%s/%s" , path, filename); +snprintf (filepath,sizeof (filepath),"%s/%s" , path, filename); fd =fopen (filepath,"w" );if (!fd) {
@@ -57,9 +58,9 @@ static int sysfs_get_ulong(char *path, char *filename, unsigned long *p_ulong) {FILE *fd;int ret =-1 ; -char filepath[256 ]; +char filepath[PATH_MAX +2 ];/* NUL and '/' */ -snprintf (filepath,256 ,"%s/%s" , path, filename); +snprintf (filepath,sizeof (filepath),"%s/%s" , path, filename); fd =fopen (filepath,"r" );if (!fd) {
@@ -76,9 +77,9 @@ static int sysfs_get_string(char *path, char *filename, char *str) {FILE *fd;int ret =-1 ; -char filepath[256 ]; +char filepath[PATH_MAX +2 ];/* NUL and '/' */ -snprintf (filepath,256 ,"%s/%s" , path, filename); +snprintf (filepath,sizeof (filepath),"%s/%s" , path, filename); fd =fopen (filepath,"r" );if (!fd) {
@@ -199,8 +200,8 @@ static int find_tzone_cdev(struct dirent *nl, char *tz_name, {unsigned long trip_instance =0 ;char cdev_name_linked[256 ]; -char cdev_name[256 ]; -char cdev_trip_name[256 ]; +char cdev_name[PATH_MAX ]; +char cdev_trip_name[PATH_MAX ];int cdev_id;if (nl->d_type ==DT_LNK ) {
@@ -213,7 +214,8 @@ static int find_tzone_cdev(struct dirent *nl, char *tz_name,return -EINVAL ; }/* find the link to real cooling device record binding */ -snprintf (cdev_name,256 ,"%s/%s" , tz_name, nl->d_name); +snprintf (cdev_name,sizeof (cdev_name) -2 ,"%s/%s" , + tz_name, nl->d_name);memset (cdev_name_linked,0 ,sizeof (cdev_name_linked));if (readlink (cdev_name, cdev_name_linked,sizeof (cdev_name_linked) -1 ) !=-1 ) {
@@ -226,8 +228,8 @@ static int find_tzone_cdev(struct dirent *nl, char *tz_name,/* find the trip point in which the cdev is binded to * in this tzone */ -snprintf (cdev_trip_name,256 ,"%s%s" , nl->d_name, -"_trip_point" ); +snprintf (cdev_trip_name,sizeof (cdev_trip_name) -1 , +"%s%s" , nl->d_name,"_trip_point" );sysfs_get_ulong (tz_name, cdev_trip_name, &trip_instance);/* validate trip point range, e.g. trip could return -1
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 434/545 sched: Fix the check of nr_running at queue wakelist
In reply to Greg Kroah-HartmanFrom: Tianchen Ding <[email protected]>
[ Upstream commit 28156108fecb1f808b21d216e8ea8f0d205a530c ]
The commit 2ebb17717550 ("sched/core: Offload wakee task activation if it the wakee is descheduling") checked rq->nr_running <= 1 to avoid task stacking when WF_ON_CPU.
Per the ordering of writes to p->on_rq and p->on_cpu, observing p->on_cpu (WF_ON_CPU) in ttwu_queue_cond() implies !p->on_rq, IOW p has gone through the deactivate_task() in __schedule(), thus p has been accounted out of rq->nr_running. As such, the task being the only runnable task on the rq implies reading rq->nr_running == 0 at that point.
The benchmark result is in [1].
[1] https://lore.kernel.org/all/[email protected]/
--- kernel/sched/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/sched/core.c +5 -1
@@ -2671,8 +2671,12 @@ static inline bool ttwu_queue_cond(int cpu, int wake_flags)* CPU then use the wakelist to offload the task activation to * the soon-to-be-idle CPU as the current CPU is likely busy. * nr_running is checked to avoid unnecessary task stacking. +* +* Note that we can only get here with (wakee) p->on_rq=0, +* p->on_cpu can be whatever, we've done the dequeue, so +* the wakee has been accounted out of ->nr_running. */ -if ((wake_flags &WF_ON_CPU ) &&cpu_rq (cpu)->nr_running <=1 ) +if ((wake_flags &WF_ON_CPU ) && !cpu_rq (cpu)->nr_running)return true;return false;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 435/545 x86/entry: Build thunk_$(BITS) only if CONFIG_PREEMPTION=y
In reply to Greg Kroah-HartmanFrom: Andrea Righi <[email protected]>
[ Upstream commit de979c83574abf6e78f3fa65b716515c91b2613d ]
With CONFIG_PREEMPTION disabled, arch/x86/entry/thunk_$(BITS).o becomes an empty object file.
With some old versions of binutils (i.e., 2.35.90.20210113-1ubuntu1) the GNU assembler doesn't generate a symbol table for empty object files and objtool fails with the following error when a valid symbol table cannot be found:
arch/x86/entry/thunk_64.o: warning: objtool: missing symbol table
To prevent this from happening, build thunk_$(BITS).o only if CONFIG_PREEMPTION is enabled.
--- arch/x86/entry/Makefile | 3 ++- arch/x86/entry/thunk_32.S | 2 -- arch/x86/entry/thunk_64.S | 4 ---- arch/x86/um/Makefile | 3 ++- 4 files changed, 4 insertions(+), 8 deletions(-)
arch/x86/entry/Makefile +2 -1
@@ -21,12 +21,13 @@ CFLAGS_syscall_64.o += $(call cc-option,-Wno-override-init,) CFLAGS_syscall_32.o += $(call cc-option,-Wno-override-init,) CFLAGS_syscall_x32.o += $(call cc-option,-Wno-override-init,) -obj-y := entry.o entry_$(BITS).o thunk_$(BITS).o syscall_$(BITS).o +obj-y := entry.o entry_$(BITS).o syscall_$(BITS).o obj-y += common.o obj-y += vdso/ obj-y += vsyscall/ +obj-$(CONFIG_PREEMPTION) += thunk_$(BITS).o obj-$(CONFIG_IA32_EMULATION) += entry_64_compat.o syscall_32.o obj-$(CONFIG_X86_X32_ABI) += syscall_x32.o
arch/x86/entry/thunk_32.S +0 -2
@@ -29,10 +29,8 @@ SYM_CODE_START_NOALIGN(\name) SYM_CODE_END(\name) .endm -#ifdef CONFIG_PREEMPTION THUNK preempt_schedule_thunk, preempt_schedule THUNK preempt_schedule_notrace_thunk, preempt_schedule_notrace EXPORT_SYMBOL(preempt_schedule_thunk) EXPORT_SYMBOL(preempt_schedule_notrace_thunk) -#endif
arch/x86/entry/thunk_64.S +0 -4
@@ -36,14 +36,11 @@ SYM_FUNC_END(\name) _ASM_NOKPROBE(\name) .endm -#ifdef CONFIG_PREEMPTION THUNK preempt_schedule_thunk, preempt_schedule THUNK preempt_schedule_notrace_thunk, preempt_schedule_notrace EXPORT_SYMBOL(preempt_schedule_thunk) EXPORT_SYMBOL(preempt_schedule_notrace_thunk) -#endif -#ifdef CONFIG_PREEMPTION SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore) popq %r11 popq %r10
@@ -58,4 +55,3 @@ SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore) RET _ASM_NOKPROBE(__thunk_restore) SYM_CODE_END(__thunk_restore) -#endif
arch/x86/um/Makefile +2 -1
@@ -27,7 +27,8 @@ else obj-y += syscalls_64.o vdso/ -subarch-y = ../lib/csum-partial_64.o ../lib/memcpy_64.o ../entry/thunk_64.o +subarch-y = ../lib/csum-partial_64.o ../lib/memcpy_64.o +subarch-$(CONFIG_PREEMPTION) += ../entry/thunk_64.o endif
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 436/545 video: fbdev: vt8623fb: Check the size of screen before memset_io()
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit ec0754c60217248fa77cc9005d66b2b55200ac06 ]
In the function vt8623fb_set_par(), the value of 'screen_size' is calculated by the user input. If the user provides the improper value, the value of 'screen_size' may larger than 'info->screen_size', which may cause the following bug:
[ 583.339036] BUG: unable to handle page fault for address: ffffc90005000000 [ 583.339049] #PF: supervisor write access in kernel mode [ 583.339052] #PF: error_code(0x0002) - not-present page [ 583.339074] RIP: 0010:memset_orig+0x33/0xb0 [ 583.339110] Call Trace: [ 583.339118] vt8623fb_set_par+0x11cd/0x21e0 [ 583.339146] fb_set_var+0x604/0xeb0 [ 583.339181] do_fb_ioctl+0x234/0x670 [ 583.339209] fb_ioctl+0xdd/0x130
Fix the this by checking the value of 'screen_size' before memset_io().
--- drivers/video/fbdev/vt8623fb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/video/fbdev/vt8623fb.c +2 -0
@@ -504,6 +504,8 @@ static int vt8623fb_set_par(struct fb_info *info) (info->var.vmode &FB_VMODE_DOUBLE ) ?2 :1 ,1 , 1, info->node); +if (screen_size > info->screen_size) + screen_size = info->screen_size;memset_io (info->screen_base,0x00 , screen_size);/* Device and screen back on */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 437/545 video: fbdev: arkfb: Check the size of screen before memset_io()
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 96b550971c65d54d64728d8ba973487878a06454 ]
In the function arkfb_set_par(), the value of 'screen_size' is calculated by the user input. If the user provides the improper value, the value of 'screen_size' may larger than 'info->screen_size', which may cause the following bug:
[ 659.399066] BUG: unable to handle page fault for address: ffffc90003000000 [ 659.399077] #PF: supervisor write access in kernel mode [ 659.399079] #PF: error_code(0x0002) - not-present page [ 659.399094] RIP: 0010:memset_orig+0x33/0xb0 [ 659.399116] Call Trace: [ 659.399122] arkfb_set_par+0x143f/0x24c0 [ 659.399130] fb_set_var+0x604/0xeb0 [ 659.399161] do_fb_ioctl+0x234/0x670 [ 659.399189] fb_ioctl+0xdd/0x130
Fix the this by checking the value of 'screen_size' before memset_io().
--- drivers/video/fbdev/arkfb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/video/fbdev/arkfb.c +2 -0
@@ -794,6 +794,8 @@ static int arkfb_set_par(struct fb_info *info) value = ((value * hmul / hdiv) /8 ) -5 ;vga_wcrt (par->state.vgabase,0x42 , (value +1 ) /2 ); +if (screen_size > info->screen_size) + screen_size = info->screen_size;memset_io (info->screen_base,0x00 , screen_size);/* Device and screen back on */ svga_wcrt_mask (par->state.vgabase,0x17 ,0x80 ,0x80 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 438/545 video: fbdev: s3fb: Check the size of screen before memset_io()
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 6ba592fa014f21f35a8ee8da4ca7b95a018f13e8 ]
In the function s3fb_set_par(), the value of 'screen_size' is calculated by the user input. If the user provides the improper value, the value of 'screen_size' may larger than 'info->screen_size', which may cause the following bug:
[ 54.083733] BUG: unable to handle page fault for address: ffffc90003000000 [ 54.083742] #PF: supervisor write access in kernel mode [ 54.083744] #PF: error_code(0x0002) - not-present page [ 54.083760] RIP: 0010:memset_orig+0x33/0xb0 [ 54.083782] Call Trace: [ 54.083788] s3fb_set_par+0x1ec6/0x4040 [ 54.083806] fb_set_var+0x604/0xeb0 [ 54.083836] do_fb_ioctl+0x234/0x670
Fix the this by checking the value of 'screen_size' before memset_io().
--- drivers/video/fbdev/s3fb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/video/fbdev/s3fb.c +2 -0
@@ -902,6 +902,8 @@ static int s3fb_set_par(struct fb_info *info) value =clamp ((htotal + hsstart +1 ) /2 +2 , hsstart +4 , htotal +1 );svga_wcrt_multi (par->state.vgabase, s3_dtpc_regs, value); +if (screen_size > info->screen_size) + screen_size = info->screen_size;memset_io (info->screen_base,0x00 , screen_size);/* Device and screen back on */ svga_wcrt_mask (par->state.vgabase,0x17 ,0x80 ,0x80 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 439/545 scsi: zfcp: Fix missing auto port scan and thus missing target ports
In reply to Greg Kroah-HartmanFrom: Steffen Maier <[email protected]>
commit 4da8c5f76825269f28d6a89fa752934a4bcb6dfa upstream.
Case (1):
The only waiter on wka_port->completion_wq is zfcp_fc_wka_port_get() trying to open a WKA port. As such it should only be woken up by WKA port *open* responses, not by WKA port close responses.
Case (2):
A close WKA port response coming in just after having sent a new open WKA port request and before blocking for the open response with wait_event() in zfcp_fc_wka_port_get() erroneously renders the wait_event a NOP because the close handler overwrites wka_port->status. Hence the wait_event condition is erroneously true and it does not enter blocking state.
With non-negligible probability, the following time space sequence happens depending on timing without this fix:
user process ERP thread zfcp work queue tasklet system work queue
============ ========== =============== ======= =================
$ echo 1 > online
zfcp_ccw_set_online
zfcp_ccw_activate
zfcp_erp_adapter_reopen
msleep scan backoff zfcp_erp_strategy
| ...
| zfcp_erp_action_cleanup
| ...
| queue delayed scan_work
| queue ns_up_work
| ns_up_work:
| zfcp_fc_wka_port_get
| open wka request
| open response
| GSPN FC-GS
| RSPN FC-GS [NPIV-only]
| zfcp_fc_wka_port_put
| (--wka->refcount==0)
| sched delayed wka->work
|
~~~Case (1)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
zfcp_erp_wait
flush scan_work
| wka->work:
| wka->status=CLOSING
| close wka request
| scan_work:
| zfcp_fc_wka_port_get
| (wka->status==CLOSING)
| wka->status=OPENING
| open wka request
| wait_event
| | close response
| | wka->status=OFFLINE
| | wake_up /*WRONG*/
~~~Case (2)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| wka->work:
| wka->status=CLOSING
| close wka request
zfcp_erp_wait
flush scan_work
| scan_work:
| zfcp_fc_wka_port_get
| (wka->status==CLOSING)
| wka->status=OPENING
| open wka request
| close response
| wka->status=OFFLINE
| wake_up /*WRONG&NOP*/
| wait_event /*NOP*/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| (wka->status!=ONLINE)
| return -EIO
| return early
open response
wka->status=ONLINE
wake_up /*NOP*/So we erroneously end up with no automatic port scan. This is a big problem when it happens during boot. The timing is influenced by v3.19 commit 18f87a67e6d6 ("zfcp: auto port scan resiliency").
Fix it by fully mutually excluding zfcp_fc_wka_port_get() and zfcp_fc_wka_port_offline(). For that to work, we make the latter block until we got the response for a close WKA port. In order not to penalize the system workqueue, we move wka_port->work to our own adapter workqueue. Note that before v2.6.30 commit 828bc1212a68 ("[SCSI] zfcp: Set WKA-port to offline on adapter deactivation"), zfcp did block in zfcp_fc_wka_port_offline() as well, but with a different condition.
While at it, make non-functional cleanups to improve code reading in zfcp_fc_wka_port_get(). If we cannot send the WKA port open request, don't rely on the subsequent wait_event condition to immediately let this case pass without blocking. Also don't want to rely on the additional condition handling the refcount to be skipped just to finally return with -EIO.
--- drivers/s390/scsi/zfcp_fc.c | 29 ++++++++++++++++++++--------- drivers/s390/scsi/zfcp_fc.h | 6 ++++-- drivers/s390/scsi/zfcp_fsf.c | 4 ++-- 3 files changed, 26 insertions(+), 13 deletions(-)
drivers/s390/scsi/zfcp_fc.c +20 -9
@@ -145,27 +145,33 @@ void zfcp_fc_enqueue_event(struct zfcp_astatic int zfcp_fc_wka_port_get (struct zfcp_fc_wka_port *wka_port) { +int ret = -EIO ; +if (mutex_lock_interruptible (&wka_port->mutex))return -ERESTARTSYS ;if (wka_port->status ==ZFCP_FC_WKA_PORT_OFFLINE || wka_port->status ==ZFCP_FC_WKA_PORT_CLOSING ) { wka_port->status =ZFCP_FC_WKA_PORT_OPENING ; -if (zfcp_fsf_open_wka_port (wka_port)) +if (zfcp_fsf_open_wka_port (wka_port)) { +/* could not even send request, nothing to wait for */ wka_port->status =ZFCP_FC_WKA_PORT_OFFLINE ; + goto out; + } } -mutex_unlock (&wka_port->mutex); - -wait_event (wka_port->completion_wq, +wait_event (wka_port->opened, wka_port->status ==ZFCP_FC_WKA_PORT_ONLINE || wka_port->status ==ZFCP_FC_WKA_PORT_OFFLINE );if (wka_port->status ==ZFCP_FC_WKA_PORT_ONLINE ) {atomic_inc (&wka_port->refcount); -return 0 ; + ret =0 ; + goto out; } -return -EIO ; +out: +mutex_unlock (&wka_port->mutex); +return ret; }static void zfcp_fc_wka_port_offline (struct work_struct *work)
@@ -181,9 +187,12 @@ static void zfcp_fc_wka_port_offline(str wka_port->status =ZFCP_FC_WKA_PORT_CLOSING ;if (zfcp_fsf_close_wka_port (wka_port)) { +/* could not even send request, nothing to wait for */ wka_port->status =ZFCP_FC_WKA_PORT_OFFLINE ; -wake_up (&wka_port->completion_wq); + goto out; } +wait_event (wka_port->closed, + wka_port->status ==ZFCP_FC_WKA_PORT_OFFLINE ); out:mutex_unlock (&wka_port->mutex); }
@@ -193,13 +202,15 @@ static void zfcp_fc_wka_port_put(structif (atomic_dec_return (&wka_port->refcount) !=0 )return ;/* wait 10 milliseconds, other reqs might pop in */ -schedule_delayed_work (&wka_port->work,HZ /100 ); +queue_delayed_work (wka_port->adapter->work_queue, &wka_port->work, +msecs_to_jiffies (10 )); }static void zfcp_fc_wka_port_init (struct zfcp_fc_wka_port *wka_port,u32 d_id,struct zfcp_adapter *adapter) { -init_waitqueue_head (&wka_port->completion_wq); +init_waitqueue_head (&wka_port->opened); +init_waitqueue_head (&wka_port->closed); wka_port->adapter = adapter; wka_port->d_id = d_id;
drivers/s390/scsi/zfcp_fc.h +4 -2
@@ -185,7 +185,8 @@ enum zfcp_fc_wka_status {/** * struct zfcp_fc_wka_port - representation of well-known-address (WKA) FC port * @adapter: Pointer to adapter structure this WKA port belongs to -* @completion_wq: Wait for completion of open/close command +* @opened: Wait for completion of open command +* @closed: Wait for completion of close command * @status: Current status of WKA port * @refcount: Reference count to keep port open as long as it is in use * @d_id: FC destination id or well-known-address
@@ -195,7 +196,8 @@ enum zfcp_fc_wka_status {*/ struct zfcp_fc_wka_port {struct zfcp_adapter *adapter; -wait_queue_head_t completion_wq; +wait_queue_head_t opened; +wait_queue_head_t closed;enum zfcp_fc_wka_status status;atomic_t refcount;u32 d_id;
drivers/s390/scsi/zfcp_fsf.c +2 -2
@@ -1889,7 +1889,7 @@ static void zfcp_fsf_open_wka_port_handl wka_port->status =ZFCP_FC_WKA_PORT_ONLINE ; } out: -wake_up (&wka_port->completion_wq); +wake_up (&wka_port->opened); }/**
@@ -1948,7 +1948,7 @@ static void zfcp_fsf_close_wka_port_hand } wka_port->status =ZFCP_FC_WKA_PORT_OFFLINE ; -wake_up (&wka_port->completion_wq); +wake_up (&wka_port->closed); }/**
Greg Kroah-Hartman
maintainerPATCH 440/545 scsi: qla2xxx: Fix discovery issues in FC-AL topology
In reply to Greg Kroah-HartmanFrom: Arun Easi <[email protected]>
commit 47ccb113cead905bdc236571bf8ac6fed90321b3 upstream.
A direct attach tape device, when gets swapped with another, was not discovered. Fix this by looking at loop map and reinitialize link if there are devices present.
--- drivers/scsi/qla2xxx/qla_gbl.h | 3 ++- drivers/scsi/qla2xxx/qla_init.c | 29 +++++++++++++++++++++++++++++ drivers/scsi/qla2xxx/qla_mbx.c | 5 ++++- 3 files changed, 35 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_gbl.h +2 -1
@@ -405,7 +405,8 @@ extern intqla2x00_get_resource_cnts (scsi_qla_host_t *);extern int -qla2x00_get_fcal_position_map (scsi_qla_host_t *ha,char *pos_map); +qla2x00_get_fcal_position_map (scsi_qla_host_t *ha,char *pos_map, +u8 *num_entries); extern int qla2x00_get_link_status(scsi_qla_host_t *, uint16_t, struct link_statistics *,
drivers/scsi/qla2xxx/qla_init.c +29 -0
@@ -5270,6 +5270,22 @@ static int qla2x00_configure_n2n_loop(screturn QLA_FUNCTION_FAILED ; } +static void +qla_reinitialize_link (scsi_qla_host_t *vha) +{ +int rval; + +atomic_set (&vha->loop_state,LOOP_DOWN ); +atomic_set (&vha->loop_down_timer,LOOP_DOWN_TIME ); + rval =qla2x00_full_login_lip (vha); +if (rval ==QLA_SUCCESS ) { +ql_dbg (ql_dbg_disc, vha,0xd050 ,"Link reinitialized\n" ); + }else { +ql_dbg (ql_dbg_disc, vha,0xd051 , +"Link reinitialization failed (%d)\n" , rval); + } +} +/* * qla2x00_configure_local_loop * Updates Fibre Channel Device Database with local loop devices.
@@ -5321,6 +5337,19 @@ qla2x00_configure_local_loop(scsi_qla_hospin_unlock_irqrestore (&vha->work_lock, flags);if (vha->scan.scan_retry <MAX_SCAN_RETRIES ) { +u8 loop_map_entries =0 ; +int rc; + + rc =qla2x00_get_fcal_position_map (vha,NULL , + &loop_map_entries); +if (rc ==QLA_SUCCESS && loop_map_entries >1 ) { +/* +* There are devices that are still not logged +* in. Reinitialize to give them a chance. +*/ +qla_reinitialize_link (vha); +return QLA_FUNCTION_FAILED ; + }set_bit (LOCAL_LOOP_UPDATE , &vha->dpc_flags);set_bit (LOOP_RESYNC_NEEDED , &vha->dpc_flags); }
drivers/scsi/qla2xxx/qla_mbx.c +4 -1
@@ -3017,7 +3017,8 @@ qla2x00_get_resource_cnts(scsi_qla_host_* Kernel context. */ int -qla2x00_get_fcal_position_map (scsi_qla_host_t *vha,char *pos_map) +qla2x00_get_fcal_position_map (scsi_qla_host_t *vha,char *pos_map, +u8 *num_entries) {int rval;mbx_cmd_t mc;
@@ -3057,6 +3058,8 @@ qla2x00_get_fcal_position_map(scsi_qla_hif (pos_map)memcpy (pos_map, pmap,FCAL_MAP_SIZE ); +if (num_entries) + *num_entries = pmap[0 ]; }dma_pool_free (ha->s_dma_pool, pmap, pmap_dma);
Greg Kroah-Hartman
maintainerPATCH 441/545 scsi: qla2xxx: Turn off multi-queue for 8G adapters
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit 5304673bdb1635e27555bd636fd5d6956f1cd552 upstream.
For 8G adapters, multi-queue was enabled accidentally. Make sure multi-queue is not enabled.
--- drivers/scsi/qla2xxx/qla_def.h | 4 ++-- drivers/scsi/qla2xxx/qla_isr.c | 16 ++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +2 -2
@@ -4135,8 +4135,8 @@ struct qla_hw_data {#define IS_OEM_001 (ha) ((ha)->device_type & DT_OEM_001)#define HAS_EXTENDED_IDS (ha) ((ha)->device_type & DT_EXTENDED_IDS)#define IS_CT6_SUPPORTED (ha) ((ha)->device_type & DT_CT6_SUPPORTED) -#define IS_MQUE_CAPABLE (ha) ((ha)->mqenable || IS_QLA83XX(ha) || \ - IS_QLA27XX(ha) || IS_QLA28XX(ha)) +#define IS_MQUE_CAPABLE (ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha) || \ + IS_QLA28XX(ha))#define IS_BIDI_CAPABLE (ha) \ (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))/* Bit 21 of fw_attributes decides the MCTP capabilities */
drivers/scsi/qla2xxx/qla_isr.c +6 -10
@@ -4054,16 +4054,12 @@ msix_register_fail: }/* Enable MSI-X vector for response queue update for queue 0 */ -if (IS_QLA83XX (ha) ||IS_QLA27XX (ha) ||IS_QLA28XX (ha)) { -if (ha->msixbase && ha->mqiobase && - (ha->max_rsp_queues >1 || ha->max_req_queues >1 || - ql2xmqsupport)) - ha->mqenable =1 ; - }else -if (ha->mqiobase && - (ha->max_rsp_queues >1 || ha->max_req_queues >1 || - ql2xmqsupport)) - ha->mqenable =1 ; +if (IS_MQUE_CAPABLE (ha) && + (ha->msixbase && ha->mqiobase && ha->max_qpairs)) + ha->mqenable =1 ; +else + ha->mqenable =0 ; +ql_dbg (ql_dbg_multiq, vha,0xc005 ,"mqiobase=%p, max_rsp_queues=%d, max_req_queues=%d.\n" , ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues);
Greg Kroah-Hartman
maintainerPATCH 442/545 scsi: qla2xxx: Fix erroneous mailbox timeout after PCI error injection
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit f260694e6463b63ae550aad25ddefe94cb1904da upstream.
Clear wait for mailbox interrupt flag to prevent stale mailbox:
Feb 22 05:22:56 ltcden4-lp7 kernel: qla2xxx [0135:90:00.1]-500a:4: LOOP UP detected (16 Gbps). Feb 22 05:22:59 ltcden4-lp7 kernel: qla2xxx [0135:90:00.1]-d04c:4: MBX Command timeout for cmd 69, ...
To fix the issue, driver needs to clear the MBX_INTR_WAIT flag on purging the mailbox. When the stale mailbox completion does arrive, it will be dropped.
--- drivers/scsi/qla2xxx/qla_mbx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/qla2xxx/qla_mbx.c +6 -6
@@ -271,6 +271,12 @@ qla2x00_mailbox_command(scsi_qla_host_tatomic_inc (&ha->num_pend_mbx_stage3);if (!wait_for_completion_timeout (&ha->mbx_intr_comp, mcp->tov *HZ )) { +ql_dbg (ql_dbg_mbx, vha,0x117a , +"cmd=%x Timeout.\n" , command); +spin_lock_irqsave (&ha->hardware_lock, flags); +clear_bit (MBX_INTR_WAIT , &ha->mbx_cmd_flags); +spin_unlock_irqrestore (&ha->hardware_lock, flags); +if (chip_reset != ha->chip_reset) {spin_lock_irqsave (&ha->hardware_lock, flags); ha->flags.mbox_busy =0 ;
@@ -281,12 +287,6 @@ qla2x00_mailbox_command(scsi_qla_host_t rval =QLA_ABORTED ; goto premature_exit; } -ql_dbg (ql_dbg_mbx, vha,0x117a , -"cmd=%x Timeout.\n" , command); -spin_lock_irqsave (&ha->hardware_lock, flags); -clear_bit (MBX_INTR_WAIT , &ha->mbx_cmd_flags); -spin_unlock_irqrestore (&ha->hardware_lock, flags); - }else if (ha->flags.purge_mbox || chip_reset != ha->chip_reset) {spin_lock_irqsave (&ha->hardware_lock, flags);
Greg Kroah-Hartman
maintainerPATCH 443/545 scsi: qla2xxx: Fix losing FCP-2 targets on long port disable with I/Os
In reply to Greg Kroah-HartmanFrom: Arun Easi <[email protected]>
commit 2416ccd3815ba1613e10a6da0a24ef21acfe5633 upstream.
FCP-2 devices were not coming back online once they were lost, login retries exhausted, and then came back up. Fix this by accepting RSCN when the device is not online.
--- drivers/scsi/qla2xxx/qla_init.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +8 -4
@@ -1734,7 +1734,8 @@ void qla2x00_handle_rscn(scsi_qla_host_tcase RSCN_PORT_ADDR : fcport =qla2x00_find_fcport_by_nportid (vha, &ea->id,1 );if (fcport) { -if (fcport->flags &FCF_FCP2_DEVICE ) { +if (fcport->flags &FCF_FCP2_DEVICE && +atomic_read (&fcport->state) ==FCS_ONLINE ) {ql_dbg (ql_dbg_disc, vha,0x2115 ,"Delaying session delete for FCP2 portid=%06x %8phC " , fcport->d_id.b24, fcport->port_name);
@@ -1746,7 +1747,8 @@ void qla2x00_handle_rscn(scsi_qla_host_tbreak ;case RSCN_AREA_ADDR :list_for_each_entry (fcport, &vha->vp_fcports, list) { -if (fcport->flags &FCF_FCP2_DEVICE ) +if (fcport->flags &FCF_FCP2_DEVICE && +atomic_read (&fcport->state) ==FCS_ONLINE )continue ;if ((ea->id.b24 &0xffff00 ) == (fcport->d_id.b24 &0xffff00 )) {
@@ -1757,7 +1759,8 @@ void qla2x00_handle_rscn(scsi_qla_host_tbreak ;case RSCN_DOM_ADDR :list_for_each_entry (fcport, &vha->vp_fcports, list) { -if (fcport->flags &FCF_FCP2_DEVICE ) +if (fcport->flags &FCF_FCP2_DEVICE && +atomic_read (&fcport->state) ==FCS_ONLINE )continue ;if ((ea->id.b24 &0xff0000 ) == (fcport->d_id.b24 &0xff0000 )) {
@@ -1769,7 +1772,8 @@ void qla2x00_handle_rscn(scsi_qla_host_tcase RSCN_FAB_ADDR :default :list_for_each_entry (fcport, &vha->vp_fcports, list) { -if (fcport->flags &FCF_FCP2_DEVICE ) +if (fcport->flags &FCF_FCP2_DEVICE && +atomic_read (&fcport->state) ==FCS_ONLINE )continue ; fcport->scan_needed =1 ;
Greg Kroah-Hartman
maintainerPATCH 444/545 scsi: qla2xxx: Fix losing FCP-2 targets during port perturbation tests
In reply to Greg Kroah-HartmanFrom: Arun Easi <[email protected]>
commit 58d1c124cd79ea686b512043c5bd515590b2ed95 upstream.
When a mix of FCP-2 (tape) and non-FCP-2 targets are present, FCP-2 target state was incorrectly transitioned when both of the targets were gone. Fix this by ignoring state transition for FCP-2 targets.
--- drivers/scsi/qla2xxx/qla_gs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_gs.c +1 -1
@@ -3552,7 +3552,7 @@ login_logout: do_delete) {if (fcport->loop_id !=FC_NO_LOOP_ID ) {if (fcport->flags &FCF_FCP2_DEVICE ) - fcport->logout_on_delete =0 ; +continue ; ql_dbg(ql_dbg_disc, vha, 0x20f0, "%s %d %8phC post del sess\n",
Greg Kroah-Hartman
maintainerPATCH 445/545 x86/bugs: Enable STIBP for IBPB mitigated RETBleed
In reply to Greg Kroah-HartmanFrom: Kim Phillips <[email protected]>
commit e6cfcdda8cbe81eaf821c897369a65fec987b404 upstream.
AMD's "Technical Guidance for Mitigating Branch Type Confusion, Rev. 1.0 2022-07-12" whitepaper, under section 6.1.2 "IBPB On Privileged Mode Entry / SMT Safety" says:
Similar to the Jmp2Ret mitigation, if the code on the sibling thread cannot be trusted, software should set STIBP to 1 or disable SMT to ensure SMT safety when using this mitigation.
So, like already being done for retbleed=unret, and now also for retbleed=ibpb, force STIBP on machines that have it, and report its SMT vulnerability status accordingly.
[ bp: Remove the "we" and remove "[AMD]" applicability parameter which
doesn't work here. ]
--- Documentation/admin-guide/kernel-parameters.txt | 29 +++++++++++++++++------- arch/x86/kernel/cpu/bugs.c | 10 ++++---- 2 files changed, 27 insertions(+), 12 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +21 -8
@@ -4662,20 +4662,33 @@ Speculative Code Execution with Return Instructions) vulnerability. + AMD-based UNRET and IBPB mitigations alone do not stop + sibling threads from influencing the predictions of other + sibling threads. For that reason, STIBP is used on pro- + cessors that support it, and mitigate SMT on processors + that don't. + off - no mitigation auto - automatically select a migitation auto,nosmt - automatically select a mitigation, disabling SMT if necessary for the full mitigation (only on Zen1 and older without STIBP). - ibpb - mitigate short speculation windows on - basic block boundaries too. Safe, highest - perf impact. - unret - force enable untrained return thunks, - only effective on AMD f15h-f17h - based systems. - unret,nosmt - like unret, will disable SMT when STIBP - is not available. + ibpb - On AMD, mitigate short speculation + windows on basic block boundaries too. + Safe, highest perf impact. It also + enables STIBP if present. Not suitable + on Intel. + ibpb,nosmt - Like "ibpb" above but will disable SMT + when STIBP is not available. This is + the alternative for systems which do not + have STIBP. + unret - Force enable untrained return thunks, + only effective on AMD f15h-f17h based + systems. + unret,nosmt - Like unret, but will disable SMT when STIBP + is not available. This is the alternative for + systems which do not have STIBP. Selecting 'auto' will choose a mitigation method at run time according to the CPU.
arch/x86/kernel/cpu/bugs.c +6 -4
@@ -144,7 +144,7 @@ void __init check_bugs(void)/* * spectre_v2_user_select_mitigation() relies on the state set by * retbleed_select_mitigation(); specifically the STIBP selection is -* forced for UNRET. +* forced for UNRET or IBPB. */ spectre_v2_user_select_mitigation ();ssb_select_mitigation ();
@@ -1135,7 +1135,8 @@ spectre_v2_user_select_mitigation(void) boot_cpu_has(X86_FEATURE_AMD_STIBP_ALWAYS_ON)) mode =SPECTRE_V2_USER_STRICT_PREFERRED ; -if (retbleed_mitigation ==RETBLEED_MITIGATION_UNRET ) { +if (retbleed_mitigation ==RETBLEED_MITIGATION_UNRET || + retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) {if (mode !=SPECTRE_V2_USER_STRICT && mode !=SPECTRE_V2_USER_STRICT_PREFERRED )pr_info ("Selecting STIBP always-on mode to complement retbleed mitigation\n" );
@@ -2283,10 +2284,11 @@ static ssize_t srbds_show_state(char *bustatic ssize_t retbleed_show_state (char *buf) { -if (retbleed_mitigation ==RETBLEED_MITIGATION_UNRET ) { +if (retbleed_mitigation ==RETBLEED_MITIGATION_UNRET || + retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) {if (boot_cpu_data.x86_vendor !=X86_VENDOR_AMD && boot_cpu_data.x86_vendor !=X86_VENDOR_HYGON ) -return sprintf (buf,"Vulnerable: untrained return thunk on non-Zen uarch\n" ); +return sprintf (buf,"Vulnerable: untrained return thunk / IBPB on non-AMD based uarch\n" ); return sprintf(buf, "%s; SMT %s\n", retbleed_strings[retbleed_mitigation],
Greg Kroah-Hartman
maintainerPATCH 446/545 ftrace/x86: Add back ftrace_expected assignment
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (Google) <[email protected]>
commit ac6c1b2ca77e722a1e5d651f12f437f2f237e658 upstream.
When a ftrace_bug happens (where ftrace fails to modify a location) it is helpful to have what was at that location as well as what was expected to be there.
But with the conversion to text_poke() the variable that assigns the expected for debugging was dropped. Unfortunately, I noticed this when I needed it. Add it back.
--- arch/x86/kernel/ftrace.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/ftrace.c +1 -0
@@ -93,6 +93,7 @@ static int ftrace_verify_code(unsigned l/* Make sure it is what we expect it to be */ if (memcmp (cur_code, old_code,MCOUNT_INSN_SIZE ) !=0 ) { + ftrace_expected = old_code;WARN_ON (1 );return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 447/545 x86/olpc: fix logical not is only applied to the left hand side
In reply to Greg Kroah-HartmanFrom: Alexander Lobakin <[email protected]>
commit 3a2ba42cbd0b669ce3837ba400905f93dd06c79f upstream.
The bitops compile-time optimization series revealed one more problem in olpc-xo1-sci.c:send_ebook_state(), resulted in GCC warnings:
arch/x86/platform/olpc/olpc-xo1-sci.c: In function 'send_ebook_state':arch/x86/platform/olpc/olpc-xo1-sci.c:83:63: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
83 | if (!!test_bit(SW_TABLET_MODE, ebook_switch_idev->sw) == state)
| ^~arch/x86/platform/olpc/olpc-xo1-sci.c:83:13: note: add parentheses around left hand side expression to silence this warning
Despite this code working as intended, this redundant double negation of boolean value, together with comparing to char with no explicit conversion to bool, makes compilers think the author made some unintentional logical mistakes here. Make it the other way around and negate the char instead to silence the warnings.
--- arch/x86/platform/olpc/olpc-xo1-sci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/platform/olpc/olpc-xo1-sci.c +1 -1
@@ -80,7 +80,7 @@ static void send_ebook_state(void)return ; } -if (!!test_bit (SW_TABLET_MODE , ebook_switch_idev->sw) == state) +if (test_bit (SW_TABLET_MODE , ebook_switch_idev->sw) == !!state)return ;/* Nothing new to report. */ input_report_switch (ebook_switch_idev,SW_TABLET_MODE , state);
Greg Kroah-Hartman
maintainerPATCH 448/545 posix-cpu-timers: Cleanup CPU timers before freeing them during exec
In reply to Greg Kroah-HartmanFrom: Thadeu Lima de Souza Cascardo <[email protected]>
commit e362359ace6f87c201531872486ff295df306d13 upstream.
Commit 55e8c8eb2c7b ("posix-cpu-timers: Store a reference to a pid not a task") started looking up tasks by PID when deleting a CPU timer.
When a non-leader thread calls execve, it will switch PIDs with the leader process. Then, as it calls exit_itimers, posix_cpu_timer_del cannot find the task because the timer still points out to the old PID.
That means that armed timers won't be disarmed, that is, they won't be removed from the timerqueue_list. exit_itimers will still release their memory, and when that list is later processed, it leads to a use-after-free.
Clean up the timers from the de-threaded task before freeing them. This prevents a reported use-after-free.
--- fs/exec.c | 3 +++ 1 file changed, 3 insertions(+)
fs/exec.c +3 -0
@@ -1286,6 +1286,9 @@ int begin_new_exec(struct linux_binprm * bprm->mm =NULL ;#ifdef CONFIG_POSIX_TIMERS +spin_lock_irq (&me->sighand->siglock); +posix_cpu_timers_exit (me); +spin_unlock_irq (&me->sighand->siglock);exit_itimers (me);flush_itimer_signals ();#endif
Greg Kroah-Hartman
maintainerPATCH 449/545 Input: gscps2 - check return value of ioremap() in gscps2_probe()
In reply to Greg Kroah-HartmanFrom: Xie Shaowen <[email protected]>
commit e61b3125a4f036b3c6b87ffd656fc1ab00440ae9 upstream.
The function ioremap() in gscps2_probe() can fail, so its return value should be checked.
--- drivers/input/serio/gscps2.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/input/serio/gscps2.c +4 -0
@@ -350,6 +350,10 @@ static int __init gscps2_probe(struct pa ps2port->port = serio; ps2port->padev = dev; ps2port->addr =ioremap (hpa,GSC_STATUS +4 ); +if (!ps2port->addr) { + ret = -ENOMEM ; + goto fail_nomem; + }spin_lock_init (&ps2port->lock);gscps2_reset (ps2port);
Greg Kroah-Hartman
maintainerPATCH 450/545 __follow_mount_rcu(): verify that mount_lock remains unchanged
In reply to Greg Kroah-HartmanFrom: Al Viro <[email protected]>
commit 20aac6c60981f5bfacd66661d090d907bf1482f0 upstream.
Validate mount_lock seqcount as soon as we cross into mount in RCU mode. Sure, ->mnt_root is pinned and will remain so until we do rcu_read_unlock() anyway, and we will eventually fail to unlazy if the mount_lock had been touched, but we might run into a hard error (e.g. -ENOENT) before trying to unlazy. And it's possible to end up with RCU pathwalk racing with rename() and umount() in a way that would fail with -ENOENT while non-RCU pathwalk would've succeeded with any timings.
Once upon a time we hadn't needed that, but analysis had been subtle, brittle and went out of window as soon as RENAME_EXCHANGE had been added.
It's narrow, hard to hit and won't get you anything other than stray -ENOENT that could be arranged in much easier way with the same priveleges, but it's a bug all the same.
Cc: [email protected]
X-sky-is-falling: unlikely
--- fs/namei.c | 2 ++ 1 file changed, 2 insertions(+)
fs/namei.c +2 -0
@@ -1348,6 +1348,8 @@ static bool __follow_mount_rcu(struct na* becoming unpinned. */ flags = dentry->d_flags; +if (read_seqretry (&mount_lock, nd->m_seq)) +return false;continue ; }if (read_seqretry (&mount_lock, nd->m_seq))
Greg Kroah-Hartman
maintainerPATCH 451/545 spmi: trace: fix stack-out-of-bound access in SPMI tracing functions
In reply to Greg Kroah-HartmanFrom: David Collins <[email protected]>
commit 2af28b241eea816e6f7668d1954f15894b45d7e3 upstream.
trace_spmi_write_begin() and trace_spmi_read_end() both call memcpy() with a length of "len + 1". This leads to one extra byte being read beyond the end of the specified buffer. Fix this out-of-bound memory access by using a length of "len" instead.
Here is a KASAN log showing the issue:
BUG: KASAN: stack-out-of-bounds in trace_event_raw_event_spmi_read_end+0x1d0/0x234 Read of size 2 at addr ffffffc0265b7540 by task [email protected]/1314 ... Call trace: dump_backtrace+0x0/0x3e8 show_stack+0x2c/0x3c dump_stack_lvl+0xdc/0x11c print_address_description+0x74/0x384 kasan_report+0x188/0x268 kasan_check_range+0x270/0x2b0 memcpy+0x90/0xe8 trace_event_raw_event_spmi_read_end+0x1d0/0x234 spmi_read_cmd+0x294/0x3ac spmi_ext_register_readl+0x84/0x9c regmap_spmi_ext_read+0x144/0x1b0 [regmap_spmi] _regmap_raw_read+0x40c/0x754 regmap_raw_read+0x3a0/0x514 regmap_bulk_read+0x418/0x494 adc5_gen3_poll_wait_hs+0xe8/0x1e0 [qcom_spmi_adc5_gen3] ... __arm64_sys_read+0x4c/0x60 invoke_syscall+0x80/0x218 el0_svc_common+0xec/0x1c8 ...
addr ffffffc0265b7540 is located in stack of task [email protected]/1314 at offset 32 in frame:
adc5_gen3_poll_wait_hs+0x0/0x1e0 [qcom_spmi_adc5_gen3]
this frame has 1 object:
[32, 33) 'status'
Memory state around the buggy address:
ffffffc0265b7400: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
ffffffc0265b7480: 04 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
>ffffffc0265b7500: 00 00 00 00 f1 f1 f1 f1 01 f3 f3 f3 00 00 00 00
^
ffffffc0265b7580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffffffc0265b7600: f1 f1 f1 f1 01 f2 07 f2 f2 f2 01 f3 00 00 00 00
==================================================================--- include/trace/events/spmi.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
include/trace/events/spmi.h +6 -6
@@ -21,15 +21,15 @@ TRACE_EVENT(spmi_write_begin,__field ( u8, sid ) __field ( u16, addr ) __field ( u8, len ) -__dynamic_array ( u8, buf, len +1 ) +__dynamic_array ( u8, buf, len ) ),TP_fast_assign ( __entry->opcode = opcode; __entry->sid = sid; __entry->addr = addr; - __entry->len = len +1 ; -memcpy (__get_dynamic_array (buf), buf, len +1 ); + __entry->len = len; +memcpy (__get_dynamic_array (buf), buf, len); ), TP_printk("opc=%d sid=%02d addr=0x%04x len=%d buf=0x[%*phD]",
@@ -92,7 +92,7 @@ TRACE_EVENT(spmi_read_end,__field ( u16, addr ) __field ( int, ret ) __field ( u8, len ) -__dynamic_array ( u8, buf, len +1 ) +__dynamic_array ( u8, buf, len ) ), TP_fast_assign(
@@ -100,8 +100,8 @@ TRACE_EVENT(spmi_read_end, __entry->sid = sid; __entry->addr = addr; __entry->ret = ret; - __entry->len = len +1 ; -memcpy (__get_dynamic_array (buf), buf, len +1 ); + __entry->len = len; +memcpy (__get_dynamic_array (buf), buf, len); ), TP_printk("opc=%d sid=%02d addr=0x%04x ret=%d len=%02d buf=0x[%*phD]",
Greg Kroah-Hartman
maintainerPATCH 452/545 drm/i915/dg1: Update DMC_DEBUG3 register
In reply to Greg Kroah-HartmanFrom: Chuansheng Liu <[email protected]>
[ Upstream commit b60668cb4c57a7cc451de781ae49f5e9cc375eaf ]
Current DMC_DEBUG3(_MMIO(0x101090)) address is for TGL, it is wrong for DG1. Just like commit 5bcc95ca382e ("drm/i915/dg1: Update DMC_DEBUG register"), correct this issue for DG1 platform to avoid wrong register being read.
BSpec: 49788
v2: fix "not wrong" typo. (Jani)
--- drivers/gpu/drm/i915/display/intel_display_debugfs.c | 4 ++-- drivers/gpu/drm/i915/i915_reg.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_display_debugfs.c +2 -2
@@ -526,8 +526,8 @@ static int i915_dmc_info(struct seq_file *m, void *unused)* reg for DC3CO debugging and validation, * but TGL DMC f/w is using DMC_DEBUG3 reg for DC3CO counter. */ -seq_printf (m,"DC3CO count: %d\n" , -intel_de_read (dev_priv,DMC_DEBUG3 )); +seq_printf (m,"DC3CO count: %d\n" ,intel_de_read (dev_priv,IS_DGFX (dev_priv) ? +DG1_DMC_DEBUG3 :TGL_DMC_DEBUG3 )); }else { dc5_reg =IS_BROXTON (dev_priv) ?BXT_CSR_DC3_DC5_COUNT :SKL_CSR_DC3_DC5_COUNT ;
drivers/gpu/drm/i915/i915_reg.h +2 -1
@@ -7546,7 +7546,8 @@ enum {#define TGL_DMC_DEBUG_DC5_COUNT _MMIO(0x101084)#define TGL_DMC_DEBUG_DC6_COUNT _MMIO(0x101088) -#define DMC_DEBUG3 _MMIO(0x101090) +#define TGL_DMC_DEBUG3 _MMIO(0x101090) +#define DG1_DMC_DEBUG3 _MMIO(0x13415c)/* Display Internal Timeout Register */ #define RM_TIMEOUT _MMIO(0x42060)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 453/545 drm/mediatek: Allow commands to be sent during video mode
In reply to Greg Kroah-HartmanFrom: Julien STEPHAN <[email protected]>
[ Upstream commit 81cc7e51c4f1686b71e30046437056ece6b2cb4d ]
Mipi dsi panel drivers can use mipi_dsi_dcs_{set,get}_display_brightness() to request backlight changes.
This can be done during panel initialization (dsi is in command mode) or afterwards (dsi is in Video Mode).
When the DSI is in Video Mode, all commands are rejected.
Detect current DSI mode in mtk_dsi_host_transfer() and switch modes temporarily to allow commands to be sent.
--- drivers/gpu/drm/mediatek/mtk_dsi.c | 33 ++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-)
drivers/gpu/drm/mediatek/mtk_dsi.c +24 -9
@@ -910,24 +910,33 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,u8 read_data[16 ];void *src_addr;u8 irq_flag =CMD_DONE_INT_FLAG ; +u32 dsi_mode; +int ret; -if (readl (dsi->regs +DSI_MODE_CTRL ) &MODE ) { -DRM_ERROR ("dsi engine is not command mode\n" ); -return -EINVAL ; + dsi_mode =readl (dsi->regs +DSI_MODE_CTRL ); +if (dsi_mode &MODE ) { +mtk_dsi_stop (dsi); + ret =mtk_dsi_switch_to_cmd_mode (dsi,VM_DONE_INT_FLAG ,500 ); +if (ret) + goto restore_dsi_mode; }if (MTK_DSI_HOST_IS_READ (msg->type)) irq_flag |=LPRX_RD_RDY_INT_FLAG ; -if (mtk_dsi_host_send_cmd (dsi, msg, irq_flag) <0 ) -return -ETIME ; + ret =mtk_dsi_host_send_cmd (dsi, msg, irq_flag); +if (ret) + goto restore_dsi_mode; -if (!MTK_DSI_HOST_IS_READ (msg->type)) -return 0 ; +if (!MTK_DSI_HOST_IS_READ (msg->type)) { + recv_cnt =0 ; + goto restore_dsi_mode; + }if (!msg->rx_buf) {DRM_ERROR ("dsi receive buffer size may be NULL\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto restore_dsi_mode; }for (i =0 ; i <16 ; i++)
@@ -952,7 +961,13 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,DRM_INFO ("dsi get %d byte data from the panel address(0x%x)\n" , recv_cnt, *((u8 *)(msg->tx_buf))); -return recv_cnt; +restore_dsi_mode: +if (dsi_mode &MODE ) { +mtk_dsi_set_mode (dsi); +mtk_dsi_start (dsi); + } + +return ret <0 ? ret : recv_cnt; }static const struct mipi_dsi_host_ops mtk_dsi_ops = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 454/545 drm/mediatek: Keep dsi as LP00 before dcs cmds transfer
In reply to Greg Kroah-HartmanFrom: Jitao Shi <[email protected]>
[ Upstream commit 39e8d062b03c3dc257d880d82bd55cdd9e185a3b ]
To comply with the panel sequence, hold the mipi signal to LP00 before the dcs cmds transmission, and pull the mipi signal high from LP00 to LP11 until the start of the dcs cmds transmission.
The normal panel timing is :
(1) pp1800 DC pull up
(2) avdd & avee AC pull high
(3) lcm_reset pull high -> pull low -> pull high
(4) Pull MIPI signal high (LP11) -> initial code -> send video data (HS mode)
The power-off sequence is reversed.
If dsi is not in cmd mode, then dsi will pull the mipi signal high in the mtk_output_dsi_enable function. The delay in lane_ready func is the reaction time of dsi_rx after pulling up the mipi signal.
--- drivers/gpu/drm/mediatek/mtk_dsi.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/gpu/drm/mediatek/mtk_dsi.c +21 -7
@@ -202,6 +202,7 @@ struct mtk_dsi {struct mtk_phy_timing phy_timing;int refcount;bool enabled; +bool lanes_ready;u32 irq_data;wait_queue_head_t irq_wait_queue;const struct mtk_dsi_driver_data *driver_data;
@@ -644,18 +645,11 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)mtk_dsi_reset_engine (dsi);mtk_dsi_phy_timconfig (dsi); -mtk_dsi_rxtx_control (dsi); -usleep_range (30 ,100 ); -mtk_dsi_reset_dphy (dsi);mtk_dsi_ps_control_vact (dsi);mtk_dsi_set_vm_cmd (dsi);mtk_dsi_config_vdo_timing (dsi);mtk_dsi_set_interrupt_enable (dsi); -mtk_dsi_clk_ulp_mode_leave (dsi); -mtk_dsi_lane0_ulp_mode_leave (dsi); -mtk_dsi_clk_hs_mode (dsi,0 ); -return 0 ; err_disable_engine_clk:clk_disable_unprepare (dsi->engine_clk);
@@ -686,6 +680,23 @@ static void mtk_dsi_poweroff(struct mtk_dsi *dsi)clk_disable_unprepare (dsi->digital_clk);phy_power_off (dsi->phy); + + dsi->lanes_ready = false; +} + +static void mtk_dsi_lane_ready (struct mtk_dsi *dsi) +{ +if (!dsi->lanes_ready) { + dsi->lanes_ready = true; +mtk_dsi_rxtx_control (dsi); +usleep_range (30 ,100 ); +mtk_dsi_reset_dphy (dsi); +mtk_dsi_clk_ulp_mode_leave (dsi); +mtk_dsi_lane0_ulp_mode_leave (dsi); +mtk_dsi_clk_hs_mode (dsi,0 ); +msleep (20 ); +/* The reaction time after pulling up the mipi signal for dsi_rx */ + } }static void mtk_output_dsi_enable (struct mtk_dsi *dsi)
@@ -693,6 +704,7 @@ static void mtk_output_dsi_enable(struct mtk_dsi *dsi)if (dsi->enabled)return ; +mtk_dsi_lane_ready (dsi);mtk_dsi_set_mode (dsi);mtk_dsi_clk_hs_mode (dsi,1 );
@@ -924,6 +936,8 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,if (MTK_DSI_HOST_IS_READ (msg->type)) irq_flag |=LPRX_RD_RDY_INT_FLAG ; +mtk_dsi_lane_ready (dsi); + ret =mtk_dsi_host_send_cmd (dsi, msg, irq_flag);if (ret) goto restore_dsi_mode;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 455/545 HID: Ignore battery for Elan touchscreen on HP Spectre X360 15-df0xxx
In reply to Greg Kroah-HartmanFrom: Elia Devito <[email protected]>
[ Upstream commit decfe496fe77061dea658a0bfa11afd4f92b540d ]
Battery status is reported for the HP Spectre X360 Convertible 15-df0xxx even if it does not have a battery. Prevent it to always report the battery as low.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-input.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -389,6 +389,7 @@#define USB_DEVICE_ID_TOSHIBA_CLICK_L9W 0x0401#define USB_DEVICE_ID_HP_X2 0x074d#define USB_DEVICE_ID_HP_X2_10_COVER 0x0755 +#define I2C_DEVICE_ID_HP_SPECTRE_X360_15 0x2817#define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN 0x2706#define USB_VENDOR_ID_ELECOM 0x056e
drivers/hid/hid-input.c +2 -0
@@ -324,6 +324,8 @@ static const struct hid_device_id hid_battery_quirks[] = { HID_BATTERY_QUIRK_IGNORE }, {HID_USB_DEVICE (USB_VENDOR_ID_ELAN ,USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN ), HID_BATTERY_QUIRK_IGNORE }, + { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_15), + HID_BATTERY_QUIRK_IGNORE }, {} };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 456/545 HID: hid-input: add Surface Go battery quirk
In reply to Greg Kroah-HartmanFrom: Zoltan Tamas Vajda <[email protected]>
[ Upstream commit b5539722eb832441f309642fe5102cc3536f92b8 ]
The Elantech touchscreen/digitizer in the Surface Go mistakenly reports having a battery. This results in a low battery message every time you try to use the pen.
This patch adds a quirk to ignore the non-existent battery and gets rid of the false low battery messages.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-input.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -391,6 +391,7 @@#define USB_DEVICE_ID_HP_X2_10_COVER 0x0755#define I2C_DEVICE_ID_HP_SPECTRE_X360_15 0x2817#define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN 0x2706 +#define I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN 0x261A#define USB_VENDOR_ID_ELECOM 0x056e#define USB_DEVICE_ID_ELECOM_BM084 0x0061
drivers/hid/hid-input.c +2 -0
@@ -326,6 +326,8 @@ static const struct hid_device_id hid_battery_quirks[] = { HID_BATTERY_QUIRK_IGNORE }, {HID_I2C_DEVICE (USB_VENDOR_ID_ELAN ,I2C_DEVICE_ID_HP_SPECTRE_X360_15 ), HID_BATTERY_QUIRK_IGNORE }, + { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN), + HID_BATTERY_QUIRK_IGNORE }, {} };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 457/545 drm/vc4: drv: Adopt the dma configuration from the HVS or V3D component
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit da8e393e23efb60eba8959856c7df88f9859f6eb ]
vc4_drv isn't necessarily under the /soc node in DT as it is a virtual device, but it is the one that does the allocations. The DMA addresses are consumed by primarily the HVS or V3D, and those require VideoCore cache alias address mapping, and so will be under /soc.
During probe find the a suitable device node for HVS or V3D, and adopt the DMA configuration of that node.
--- drivers/gpu/drm/vc4/vc4_drv.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/gpu/drm/vc4/vc4_drv.c +19 -0
@@ -246,6 +246,15 @@ static void vc4_match_add_drivers(struct device *dev, } } +const struct of_device_id vc4_dma_range_matches[] = { + { .compatible ="brcm,bcm2711-hvs" }, + { .compatible ="brcm,bcm2835-hvs" }, + { .compatible ="brcm,bcm2835-v3d" }, + { .compatible ="brcm,cygnus-v3d" }, + { .compatible ="brcm,vc4-v3d" }, + {} +}; +static int vc4_drm_bind (struct device *dev) {struct platform_device *pdev =to_platform_device (dev);
@@ -263,6 +272,16 @@ static int vc4_drm_bind(struct device *dev) vc4_drm_driver.driver_features &= ~DRIVER_RENDER ;of_node_put (node); + node =of_find_matching_node_and_match (NULL , vc4_dma_range_matches, +NULL ); +if (node) { + ret =of_dma_configure (dev, node, true); +of_node_put (node); + +if (ret) +return ret; + } + vc4 = devm_drm_dev_alloc(dev, &vc4_drm_driver, struct vc4_dev, base);if (IS_ERR (vc4))return PTR_ERR (vc4);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 458/545 mtd: rawnand: Add a helper to clarify the interface configuration
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
[ Upstream commit 961965c45c706175b24227868b1c12d72775e446 ]
Name it nand_interface_is_sdr() which will make even more sense when nand_interface_is_nvddr() will be introduced.
Use it when relevant.
--- drivers/mtd/nand/raw/atmel/nand-controller.c | 2 +- include/linux/mtd/rawnand.h | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +1 -1
@@ -1246,7 +1246,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand, nc =to_nand_controller (nand->base.controller);/* DDR interface not supported. */ -if (conf->type !=NAND_SDR_IFACE ) +if (!nand_interface_is_sdr (conf))return -ENOTSUPP ;/*
include/linux/mtd/rawnand.h +10 -1
@@ -499,6 +499,15 @@ struct nand_interface_config { } timings; }; +/** +* nand_interface_is_sdr - get the interface type +* @conf: The data interface +*/ +static bool nand_interface_is_sdr (const struct nand_interface_config *conf) +{ +return conf->type ==NAND_SDR_IFACE ; +} +/** * nand_get_sdr_timings - get SDR timing from data interface * @conf: The data interface
@@ -506,7 +515,7 @@ struct nand_interface_config {static inline const struct nand_sdr_timings *nand_get_sdr_timings (const struct nand_interface_config *conf) { -if (conf->type !=NAND_SDR_IFACE ) +if (!nand_interface_is_sdr (conf))return ERR_PTR (-EINVAL );return &conf->timings.sdr;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 459/545 mtd: rawnand: arasan: Check the proposed data interface is supported
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
[ Upstream commit 4dd7ef970bee8a93e1817ec028a7e26aef046d0d ]
Check the data interface is supported in ->setup_interface() before acknowledging the timings.
--- drivers/mtd/nand/raw/arasan-nand-controller.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/mtd/nand/raw/arasan-nand-controller.c +5 -0
@@ -884,6 +884,11 @@ static int anfc_setup_interface(struct nand_chip *chip, int target,struct anand *anand =to_anand (chip);struct arasan_nfc *nfc =to_anfc (chip->controller);struct device_node *np = nfc->dev->of_node; +const struct nand_sdr_timings *sdr; + + sdr =nand_get_sdr_timings (conf); +if (IS_ERR (sdr)) +return PTR_ERR (sdr);if (target <0 )return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 460/545 mtd: rawnand: Add NV-DDR timings
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
[ Upstream commit 1666b815ad1a5b6373e950da5002ac46521a9b28 ]
Create the relevant ONFI NV-DDR timings structure and fill it with default values from the ONFI specification.
Add the relevant structure entries and helpers.
--- drivers/mtd/nand/raw/nand_timings.c | 255 ++++++++++++++++++++++++++++ include/linux/mtd/rawnand.h | 112 ++++++++++++ 2 files changed, 367 insertions(+)
drivers/mtd/nand/raw/nand_timings.c +255 -0
@@ -292,6 +292,261 @@ static const struct nand_interface_config onfi_sdr_timings[] = { }, }; +static const struct nand_interface_config onfi_nvddr_timings[] = { +/* Mode 0 */ + { + .type =NAND_NVDDR_IFACE , + .timings.mode =0 , + .timings.nvddr = { + .tCCS_min =500000 , + .tR_max =200000000 , + .tPROG_max =1000000ULL *ONFI_DYN_TIMING_MAX , + .tBERS_max =1000000ULL *ONFI_DYN_TIMING_MAX , + .tAC_min =3000 , + .tAC_max =25000 , + .tADL_min =400000 , + .tCAD_min =45000 , + .tCAH_min =10000 , + .tCALH_min =10000 , + .tCALS_min =10000 , + .tCAS_min =10000 , + .tCEH_min =20000 , + .tCH_min =10000 , + .tCK_min =50000 , + .tCS_min =35000 , + .tDH_min =5000 , + .tDQSCK_min =3000 , + .tDQSCK_max =25000 , + .tDQSD_min =0 , + .tDQSD_max =18000 , + .tDQSHZ_max =20000 , + .tDQSQ_max =5000 , + .tDS_min =5000 , + .tDSC_min =50000 , + .tFEAT_max =1000000 , + .tITC_max =1000000 , + .tQHS_max =6000 , + .tRHW_min =100000 , + .tRR_min =20000 , + .tRST_max =500000000 , + .tWB_max =100000 , + .tWHR_min =80000 , + .tWRCK_min =20000 , + .tWW_min =100000 , + }, + }, +/* Mode 1 */ + { + .type =NAND_NVDDR_IFACE , + .timings.mode =1 , + .timings.nvddr = { + .tCCS_min =500000 , + .tR_max =200000000 , + .tPROG_max =1000000ULL *ONFI_DYN_TIMING_MAX , + .tBERS_max =1000000ULL *ONFI_DYN_TIMING_MAX , + .tAC_min =3000 , + .tAC_max =25000 , + .tADL_min =400000 , + .tCAD_min =45000 , + .tCAH_min =5000 , + .tCALH_min =5000 , + .tCALS_min =5000 , + .tCAS_min =5000 , + .tCEH_min =20000 , + .tCH_min =5000 , + .tCK_min =30000 , + .tCS_min =25000 , + .tDH_min =2500 , + .tDQSCK_min =3000 , + .tDQSCK_max =25000 , + .tDQSD_min =0 , + .tDQSD_max =18000 , + .tDQSHZ_max =20000 , + .tDQSQ_max =2500 , + .tDS_min =3000 , + .tDSC_min =30000 , + .tFEAT_max =1000000 , + .tITC_max =1000000 , + .tQHS_max =3000 , + .tRHW_min =100000 , + .tRR_min =20000 , + .tRST_max =500000000 , + .tWB_max =100000 , + .tWHR_min =80000 , + .tWRCK_min =20000 , + .tWW_min =100000 , + }, + }, +/* Mode 2 */ + { + .type =NAND_NVDDR_IFACE , + .timings.mode =2 , + .timings.nvddr = { + .tCCS_min =500000 , + .tR_max =200000000 , + .tPROG_max =1000000ULL *ONFI_DYN_TIMING_MAX , + .tBERS_max =1000000ULL *ONFI_DYN_TIMING_MAX , + .tAC_min =3000 , + .tAC_max =25000 , + .tADL_min =400000 , + .tCAD_min =45000 , + .tCAH_min =4000 , + .tCALH_min =4000 , + .tCALS_min =4000 , + .tCAS_min =4000 , + .tCEH_min =20000 , + .tCH_min =4000 , + .tCK_min =20000 , + .tCS_min =15000 , + .tDH_min =1700 , + .tDQSCK_min =3000 , + .tDQSCK_max =25000 , + .tDQSD_min =0 , + .tDQSD_max =18000 , + .tDQSHZ_max =20000 , + .tDQSQ_max =1700 , + .tDS_min =2000 , + .tDSC_min =20000 , + .tFEAT_max =1000000 , + .tITC_max =1000000 , + .tQHS_max =2000 , + .tRHW_min =100000 , + .tRR_min =20000 , + .tRST_max =500000000 , + .tWB_max =100000 , + .tWHR_min =80000 , + .tWRCK_min =20000 , + .tWW_min =100000 , + }, + }, +/* Mode 3 */ + { + .type =NAND_NVDDR_IFACE , + .timings.mode =3 , + .timings.nvddr = { + .tCCS_min =500000 , + .tR_max =200000000 , + .tPROG_max =1000000ULL *ONFI_DYN_TIMING_MAX , + .tBERS_max =1000000ULL *ONFI_DYN_TIMING_MAX , + .tAC_min =3000 , + .tAC_max =25000 , + .tADL_min =400000 , + .tCAD_min =45000 , + .tCAH_min =3000 , + .tCALH_min =3000 , + .tCALS_min =3000 , + .tCAS_min =3000 , + .tCEH_min =20000 , + .tCH_min =3000 , + .tCK_min =15000 , + .tCS_min =15000 , + .tDH_min =1300 , + .tDQSCK_min =3000 , + .tDQSCK_max =25000 , + .tDQSD_min =0 , + .tDQSD_max =18000 , + .tDQSHZ_max =20000 , + .tDQSQ_max =1300 , + .tDS_min =1500 , + .tDSC_min =15000 , + .tFEAT_max =1000000 , + .tITC_max =1000000 , + .tQHS_max =1500 , + .tRHW_min =100000 , + .tRR_min =20000 , + .tRST_max =500000000 , + .tWB_max =100000 , + .tWHR_min =80000 , + .tWRCK_min =20000 , + .tWW_min =100000 , + }, + }, +/* Mode 4 */ + { + .type =NAND_NVDDR_IFACE , + .timings.mode =4 , + .timings.nvddr = { + .tCCS_min =500000 , + .tR_max =200000000 , + .tPROG_max =1000000ULL *ONFI_DYN_TIMING_MAX , + .tBERS_max =1000000ULL *ONFI_DYN_TIMING_MAX , + .tAC_min =3000 , + .tAC_max =25000 , + .tADL_min =400000 , + .tCAD_min =45000 , + .tCAH_min =2500 , + .tCALH_min =2500 , + .tCALS_min =2500 , + .tCAS_min =2500 , + .tCEH_min =20000 , + .tCH_min =2500 , + .tCK_min =12000 , + .tCS_min =15000 , + .tDH_min =1100 , + .tDQSCK_min =3000 , + .tDQSCK_max =25000 , + .tDQSD_min =0 , + .tDQSD_max =18000 , + .tDQSHZ_max =20000 , + .tDQSQ_max =1000 , + .tDS_min =1100 , + .tDSC_min =12000 , + .tFEAT_max =1000000 , + .tITC_max =1000000 , + .tQHS_max =1200 , + .tRHW_min =100000 , + .tRR_min =20000 , + .tRST_max =500000000 , + .tWB_max =100000 , + .tWHR_min =80000 , + .tWRCK_min =20000 , + .tWW_min =100000 , + }, + }, +/* Mode 5 */ + { + .type =NAND_NVDDR_IFACE , + .timings.mode =5 , + .timings.nvddr = { + .tCCS_min =500000 , + .tR_max =200000000 , + .tPROG_max =1000000ULL *ONFI_DYN_TIMING_MAX , + .tBERS_max =1000000ULL *ONFI_DYN_TIMING_MAX , + .tAC_min =3000 , + .tAC_max =25000 , + .tADL_min =400000 , + .tCAD_min =45000 , + .tCAH_min =2000 , + .tCALH_min =2000 , + .tCALS_min =2000 , + .tCAS_min =2000 , + .tCEH_min =20000 , + .tCH_min =2000 , + .tCK_min =10000 , + .tCS_min =15000 , + .tDH_min =900 , + .tDQSCK_min =3000 , + .tDQSCK_max =25000 , + .tDQSD_min =0 , + .tDQSD_max =18000 , + .tDQSHZ_max =20000 , + .tDQSQ_max =850 , + .tDS_min =900 , + .tDSC_min =10000 , + .tFEAT_max =1000000 , + .tITC_max =1000000 , + .tQHS_max =1000 , + .tRHW_min =100000 , + .tRR_min =20000 , + .tRST_max =500000000 , + .tWB_max =100000 , + .tWHR_min =80000 , + .tWRCK_min =20000 , + .tWW_min =100000 , + }, + }, +}; +/* All NAND chips share the same reset data interface: SDR mode 0 */ const struct nand_interface_config *nand_get_reset_interface_config (void ) {
include/linux/mtd/rawnand.h +112 -0
148 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 461/545 mtd: rawnand: arasan: Fix a macro parameter
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
[ Upstream commit 698ddeb89e01840dec05ffdb538468782e641a56 ]
This macro is not yet being used so the compilers never complained about it.
Fix the macro before using it.
--- drivers/mtd/nand/raw/arasan-nand-controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/arasan-nand-controller.c +1 -1
@@ -91,7 +91,7 @@#define DATA_INTERFACE_REG 0x6C#define DIFACE_SDR_MODE (x) FIELD_PREP(GENMASK(2, 0), (x)) -#define DIFACE_DDR_MODE (x) FIELD_PREP(GENMASK(5, 3), (X)) +#define DIFACE_DDR_MODE (x) FIELD_PREP(GENMASK(5, 3), (x))#define DIFACE_SDR 0#define DIFACE_NVDDR BIT(9)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 462/545 mtd: rawnand: arasan: Support NV-DDR interface
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
[ Upstream commit 4edde60314587382e42141df2f41ca968dc20737 ]
Add support for the NV-DDR interface.
--- drivers/mtd/nand/raw/arasan-nand-controller.c | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-)
drivers/mtd/nand/raw/arasan-nand-controller.c +20 -7
@@ -885,25 +885,38 @@ static int anfc_setup_interface(struct nand_chip *chip, int target,struct arasan_nfc *nfc =to_anfc (chip->controller);struct device_node *np = nfc->dev->of_node;const struct nand_sdr_timings *sdr; - - sdr =nand_get_sdr_timings (conf); -if (IS_ERR (sdr)) -return PTR_ERR (sdr); +const struct nand_nvddr_timings *nvddr; + +if (nand_interface_is_nvddr (conf)) { + nvddr =nand_get_nvddr_timings (conf); +if (IS_ERR (nvddr)) +return PTR_ERR (nvddr); + }else { + sdr =nand_get_sdr_timings (conf); +if (IS_ERR (sdr)) +return PTR_ERR (sdr); + }if (target <0 )return 0 ; - anand->timings =DIFACE_SDR |DIFACE_SDR_MODE (conf->timings.mode); +if (nand_interface_is_sdr (conf)) + anand->timings =DIFACE_SDR | +DIFACE_SDR_MODE (conf->timings.mode); +else + anand->timings =DIFACE_NVDDR | +DIFACE_DDR_MODE (conf->timings.mode); + anand->clk =ANFC_XLNX_SDR_DFLT_CORE_CLK ;/* * Due to a hardware bug in the ZynqMP SoC, SDR timing modes 0-1 work * with f > 90MHz (default clock is 100MHz) but signals are unstable * with higher modes. Hence we decrease a little bit the clock rate to -* 80MHz when using modes 2-5 with this SoC. +* 80MHz when using SDR modes 2-5 with this SoC. */ if (of_device_is_compatible (np,"xlnx,zynqmp-nand-controller" ) && - conf->timings.mode >=2 ) +nand_interface_is_sdr (conf) && conf->timings.mode >=2 ) anand->clk =ANFC_XLNX_SDR_HS_CORE_CLK ;return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 463/545 mtd: rawnand: arasan: Fix clock rate in NV-DDR
In reply to Greg Kroah-HartmanFrom: Olga Kitaina <[email protected]>
[ Upstream commit e16eceea863b417fd328588b1be1a79de0bc937f ]
According to the Arasan NAND controller spec, the flash clock rate for SDR must be <= 100 MHz, while for NV-DDR it must be the same as the rate of the CLK line for the mode. The driver previously always set 100 MHz for NV-DDR, which would result in incorrect behavior for NV-DDR modes 0-4.
The appropriate clock rate can be calculated from the NV-DDR timing parameters as 1/tCK, or for rates measured in picoseconds, 10^12 / nand_nvddr_timings->tCK_min.
--- drivers/mtd/nand/raw/arasan-nand-controller.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/arasan-nand-controller.c +7 -1
@@ -907,7 +907,13 @@ static int anfc_setup_interface(struct nand_chip *chip, int target, anand->timings =DIFACE_NVDDR |DIFACE_DDR_MODE (conf->timings.mode); - anand->clk =ANFC_XLNX_SDR_DFLT_CORE_CLK ; +if (nand_interface_is_sdr (conf)) { + anand->clk =ANFC_XLNX_SDR_DFLT_CORE_CLK ; + }else { +/* ONFI timings are defined in picoseconds */ + anand->clk =div_u64 ((u64 )NSEC_PER_SEC *1000 , + conf->timings.nvddr.tCK_min); + }/* * Due to a hardware bug in the ZynqMP SoC, SDR timing modes 0-1 work
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 464/545 usbnet: smsc95xx: Dont clear read-only PHY interrupt
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
[ Upstream commit 3108871f19221372b251f7da1ac38736928b5b3a ]
Upon receiving data from the Interrupt Endpoint, the SMSC LAN95xx driver attempts to clear the signaled interrupts by writing "all ones" to the Interrupt Status Register.
However the driver only ever enables a single type of interrupt, namely the PHY Interrupt. And according to page 119 of the LAN950x datasheet, its bit in the Interrupt Status Register is read-only. There's no other way to clear it than in a separate PHY register:
Consequently, writing "all ones" to the Interrupt Status Register is pointless and can be dropped.
--- drivers/net/usb/smsc95xx.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/net/usb/smsc95xx.c +0 -4
@@ -570,10 +570,6 @@ static int smsc95xx_link_reset(struct usbnet *dev)unsigned long flags;int ret; - ret =smsc95xx_write_reg (dev,INT_STS ,INT_STS_CLEAR_ALL_ ); -if (ret <0 ) -return ret; -spin_lock_irqsave (&pdata->mac_cr_lock, flags);if (pdata->phydev->duplex !=DUPLEX_FULL ) { pdata->mac_cr &= ~MAC_CR_FDPX_ ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 465/545 usbnet: smsc95xx: Avoid link settings race on interrupt reception
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
[ Upstream commit 8960f878e39fadc03d74292a6731f1e914cf2019 ]
When a PHY interrupt is signaled, the SMSC LAN95xx driver updates the MAC full duplex mode and PHY flow control registers based on cached data in struct phy_device:
smsc95xx_status() # raises EVENT_LINK_RESET
usbnet_deferred_kevent()
smsc95xx_link_reset() # uses cached data in phydev
Simultaneously, phylib polls link status once per second and updates that cached data:
phy_state_machine()
phy_check_link_status()
phy_read_status()
lan87xx_read_status()
genphy_read_status() # updates cached data in phydev
If smsc95xx_link_reset() wins the race against genphy_read_status(), the registers may be updated based on stale data.
E.g. if the link was previously down, phydev->duplex is set to DUPLEX_UNKNOWN and that's what smsc95xx_link_reset() will use, even though genphy_read_status() may update it to DUPLEX_FULL afterwards.
PHY interrupts are currently only enabled on suspend to trigger wakeup, so the impact of the race is limited, but we're about to enable them perpetually.
Avoid the race by delaying execution of smsc95xx_link_reset() until phy_state_machine() has done its job and calls back via smsc95xx_handle_link_change().
Signaling EVENT_LINK_RESET on wakeup is not necessary because phylib picks up link status changes through polling. So drop the declaration of a ->link_reset() callback.
Note that the semicolon on a line by itself added in smsc95xx_status() is a placeholder for a function call which will be added in a subsequent commit. That function call will actually handle the INT_ENP_PHY_INT_ interrupt.
--- drivers/net/usb/smsc95xx.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/net/usb/smsc95xx.c +9 -7
@@ -564,7 +564,7 @@ static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev)return smsc95xx_write_reg (dev,AFC_CFG , afc_cfg); } -static int smsc95xx_link_reset (struct usbnet *dev) +static void smsc95xx_mac_update_fullduplex (struct usbnet *dev) {struct smsc95xx_priv *pdata = dev->driver_priv;unsigned long flags;
@@ -581,14 +581,16 @@ static int smsc95xx_link_reset(struct usbnet *dev)spin_unlock_irqrestore (&pdata->mac_cr_lock, flags); ret =smsc95xx_write_reg (dev,MAC_CR , pdata->mac_cr); -if (ret <0 ) -return ret; +if (ret <0 ) { +if (ret != -ENODEV ) +netdev_warn (dev->net, +"Error updating MAC full duplex mode\n" ); +return ; + } ret =smsc95xx_phy_update_flowcontrol (dev);if (ret <0 )netdev_warn (dev->net,"Error updating PHY flow control\n" ); - -return ret; }static void smsc95xx_status (struct usbnet *dev,struct urb *urb)
@@ -605,7 +607,7 @@ static void smsc95xx_status(struct usbnet *dev, struct urb *urb)netif_dbg (dev, link, dev->net,"intdata: 0x%08X\n" , intdata);if (intdata &INT_ENP_PHY_INT_ ) -usbnet_defer_kevent (dev,EVENT_LINK_RESET ); + ;else netdev_warn (dev->net,"unexpected interrupt, intdata=0x%08X\n" , intdata);
@@ -1062,6 +1064,7 @@ static void smsc95xx_handle_link_change(struct net_device *net)struct usbnet *dev =netdev_priv (net);phy_print_status (net->phydev); +smsc95xx_mac_update_fullduplex (dev);usbnet_defer_kevent (dev,EVENT_LINK_CHANGE ); }
@@ -1968,7 +1971,6 @@ static const struct driver_info smsc95xx_info = { .description = "smsc95xx USB 2.0 Ethernet", .bind = smsc95xx_bind, .unbind = smsc95xx_unbind, - .link_reset = smsc95xx_link_reset, .reset = smsc95xx_reset, .check_connect = smsc95xx_start_phy, .stop = smsc95xx_stop,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 466/545 firmware: arm_scpi: Ensure scpi_info is not assigned if the probe fails
In reply to Greg Kroah-HartmanFrom: Sudeep Holla <[email protected]>
[ Upstream commit 689640efc0a2c4e07e6f88affe6d42cd40cc3f85 ]
When scpi probe fails, at any point, we need to ensure that the scpi_info is not set and will remain NULL until the probe succeeds. If it is not taken care, then it could result use-after-free as the value is exported via get_scpi_ops() and could refer to a memory allocated via devm_kzalloc() but freed when the probe fails.
--- drivers/firmware/arm_scpi.c | 61 +++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 26 deletions(-)
drivers/firmware/arm_scpi.c +35 -26
@@ -815,7 +815,7 @@ static int scpi_init_versions(struct scpi_drvinfo *info) info->firmware_version =le32_to_cpu (caps.platform_version); }/* Ignore error if not implemented */ -if (scpi_info->is_legacy && ret == -EOPNOTSUPP ) +if (info->is_legacy && ret == -EOPNOTSUPP )return 0 ;return ret;
@@ -905,13 +905,14 @@ static int scpi_probe(struct platform_device *pdev)struct resource res;struct device *dev = &pdev->dev;struct device_node *np = dev->of_node; +struct scpi_drvinfo *scpi_drvinfo; - scpi_info =devm_kzalloc (dev,sizeof (*scpi_info),GFP_KERNEL ); -if (!scpi_info) + scpi_drvinfo =devm_kzalloc (dev,sizeof (*scpi_drvinfo),GFP_KERNEL ); +if (!scpi_drvinfo)return -ENOMEM ;if (of_match_device (legacy_scpi_of_match, &pdev->dev)) - scpi_info->is_legacy = true; + scpi_drvinfo->is_legacy = true; count =of_count_phandle_with_args (np,"mboxes" ,"#mbox-cells" );if (count <0 ) {
@@ -919,19 +920,19 @@ static int scpi_probe(struct platform_device *pdev)return -ENODEV ; } - scpi_info->channels =devm_kcalloc (dev, count,sizeof (struct scpi_chan ), -GFP_KERNEL ); -if (!scpi_info->channels) + scpi_drvinfo->channels = +devm_kcalloc (dev, count,sizeof (struct scpi_chan ),GFP_KERNEL ); +if (!scpi_drvinfo->channels)return -ENOMEM ; - ret =devm_add_action (dev, scpi_free_channels, scpi_info); + ret =devm_add_action (dev, scpi_free_channels, scpi_drvinfo);if (ret)return ret; -for (; scpi_info->num_chans < count; scpi_info->num_chans++) { +for (; scpi_drvinfo->num_chans < count; scpi_drvinfo->num_chans++) {resource_size_t size; -int idx = scpi_info->num_chans; -struct scpi_chan *pchan = scpi_info->channels + idx; +int idx = scpi_drvinfo->num_chans; +struct scpi_chan *pchan = scpi_drvinfo->channels + idx;struct mbox_client *cl = &pchan->cl;struct device_node *shmem =of_parse_phandle (np,"shmem" , idx);
@@ -975,45 +976,53 @@ static int scpi_probe(struct platform_device *pdev)return ret; } - scpi_info->commands = scpi_std_commands; + scpi_drvinfo->commands = scpi_std_commands; -platform_set_drvdata (pdev, scpi_info); +platform_set_drvdata (pdev, scpi_drvinfo); -if (scpi_info->is_legacy) { +if (scpi_drvinfo->is_legacy) {/* Replace with legacy variants */ scpi_ops.clk_set_val = legacy_scpi_clk_set_val; - scpi_info->commands = scpi_legacy_commands; + scpi_drvinfo->commands = scpi_legacy_commands;/* Fill priority bitmap */ for (idx =0 ; idx <ARRAY_SIZE (legacy_hpriority_cmds); idx++)set_bit (legacy_hpriority_cmds[idx], - scpi_info->cmd_priority); + scpi_drvinfo->cmd_priority); } - ret =scpi_init_versions (scpi_info); + scpi_info = scpi_drvinfo; + + ret =scpi_init_versions (scpi_drvinfo);if (ret) {dev_err (dev,"incorrect or no SCP firmware found\n" ); + scpi_info =NULL ;return ret; } -if (scpi_info->is_legacy && !scpi_info->protocol_version && - !scpi_info->firmware_version) +if (scpi_drvinfo->is_legacy && !scpi_drvinfo->protocol_version && + !scpi_drvinfo->firmware_version)dev_info (dev,"SCP Protocol legacy pre-1.0 firmware\n" );else dev_info (dev,"SCP Protocol %lu.%lu Firmware %lu.%lu.%lu version\n" ,FIELD_GET (PROTO_REV_MAJOR_MASK , - scpi_info->protocol_version), + scpi_drvinfo->protocol_version),FIELD_GET (PROTO_REV_MINOR_MASK , - scpi_info->protocol_version), + scpi_drvinfo->protocol_version),FIELD_GET (FW_REV_MAJOR_MASK , - scpi_info->firmware_version), + scpi_drvinfo->firmware_version),FIELD_GET (FW_REV_MINOR_MASK , - scpi_info->firmware_version), + scpi_drvinfo->firmware_version),FIELD_GET (FW_REV_PATCH_MASK , - scpi_info->firmware_version)); - scpi_info->scpi_ops = &scpi_ops; + scpi_drvinfo->firmware_version)); + + scpi_drvinfo->scpi_ops = &scpi_ops; -return devm_of_platform_populate (dev); + ret =devm_of_platform_populate (dev); +if (ret) + scpi_info =NULL ; + +return ret; }static const struct of_device_id scpi_of_match[] = {
Signature · 1 line
2.35.1