regmap: Account for register length when chunking
Subsystems (10)
Sasha Levin
maintainerPATCH 1/19 regmap: Account for register length when chunking
From: Jim Wylder <[email protected]>
[ Upstream commit 3981514180c987a79ea98f0ae06a7cbf58a9ac0f ]
Currently, when regmap_raw_write() splits the data, it uses the max_raw_write value defined for the bus. For any bus that includes the target register address in the max_raw_write value, the chunked transmission will always exceed the maximum transmission length. To avoid this problem, subtract the length of the register and the padding from the maximum transmission.
--- drivers/base/regmap/regmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/base/regmap/regmap.c +4 -2
@@ -2064,6 +2064,8 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,size_t val_count = val_len / val_bytes;size_t chunk_count, chunk_bytes;size_t chunk_regs = val_count; +size_t max_data = map->max_raw_write - map->format.reg_bytes - + map->format.pad_bytes;int ret, i;if (!val_count)
@@ -2071,8 +2073,8 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,if (map->use_single_write) chunk_regs =1 ; -else if (map->max_raw_write && val_len > map->max_raw_write) - chunk_regs = map->max_raw_write / val_bytes; +else if (map->max_raw_write && val_len > max_data) + chunk_regs = max_data / val_bytes; chunk_count = val_count / chunk_regs; chunk_bytes = chunk_regs * val_bytes;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 2/19 iommu/amd: Handle GALog overflows
From: Joao Martins <[email protected]>
[ Upstream commit af47b0a24058e56e983881993752f88288ca6511 ]
GALog exists to propagate interrupts into all vCPUs in the system when interrupts are marked as non running (e.g. when vCPUs aren't running). A GALog overflow happens when there's in no space in the log to record the GATag of the interrupt. So when the GALOverflow condition happens, the GALog queue is processed and the GALog is restarted, as the IOMMU manual indicates in section "2.7.4 Guest Virtual APIC Log Restart Procedure":
| * Wait until MMIO Offset 2020h[GALogRun]=0b so that all request | entries are completed as circumstances allow. GALogRun must be 0b to | modify the guest virtual APIC log registers safely. | * Write MMIO Offset 0018h[GALogEn]=0b. | * As necessary, change the following values (e.g., to relocate or | resize the guest virtual APIC event log): | - the Guest Virtual APIC Log Base Address Register | [MMIO Offset 00E0h], | - the Guest Virtual APIC Log Head Pointer Register | [MMIO Offset 2040h][GALogHead], and | - the Guest Virtual APIC Log Tail Pointer Register | [MMIO Offset 2048h][GALogTail]. | * Write MMIO Offset 2020h[GALOverflow] = 1b to clear the bit (W1C). | * Write MMIO Offset 0018h[GALogEn] = 1b, and either set | MMIO Offset 0018h[GAIntEn] to enable the GA log interrupt or clear | the bit to disable it.
Failing to handle the GALog overflow means that none of the VFs (in any guest) will work with IOMMU AVIC forcing the user to power cycle the host. When handling the event it resumes the GALog without resizing much like how it is done in the event handler overflow. The [MMIO Offset 2020h][GALOverflow] bit might be set in status register without the [MMIO Offset 2020h][GAInt] bit, so when deciding to poll for GA events (to clear space in the galog), also check the overflow bit.
[suravee: Check for GAOverflow without GAInt, toggle CONTROL_GAINT_EN]
--- drivers/iommu/amd/amd_iommu.h | 1 + drivers/iommu/amd/init.c | 24 ++++++++++++++++++++++++ drivers/iommu/amd/iommu.c | 9 ++++++++- 3 files changed, 33 insertions(+), 1 deletion(-)
drivers/iommu/amd/amd_iommu.h +1 -0
@@ -15,6 +15,7 @@ extern irqreturn_t amd_iommu_int_thread(int irq, void *data);extern irqreturn_t amd_iommu_int_handler (int irq,void *data);extern void amd_iommu_apply_erratum_63 (struct amd_iommu *iommu,u16 devid);extern void amd_iommu_restart_event_logging (struct amd_iommu *iommu); +extern void amd_iommu_restart_ga_log (struct amd_iommu *iommu);extern int amd_iommu_init_devices (void );extern void amd_iommu_uninit_devices (void );extern void amd_iommu_init_notifier (void );
drivers/iommu/amd/init.c +24 -0
@@ -751,6 +751,30 @@ void amd_iommu_restart_event_logging(struct amd_iommu *iommu)iommu_feature_enable (iommu,CONTROL_EVT_LOG_EN ); } +/* +* This function restarts event logging in case the IOMMU experienced +* an GA log overflow. +*/ +void amd_iommu_restart_ga_log (struct amd_iommu *iommu) +{ +u32 status; + + status =readl (iommu->mmio_base +MMIO_STATUS_OFFSET ); +if (status &MMIO_STATUS_GALOG_RUN_MASK ) +return ; + +pr_info_ratelimited ("IOMMU GA Log restarting\n" ); + +iommu_feature_disable (iommu,CONTROL_GALOG_EN ); +iommu_feature_disable (iommu,CONTROL_GAINT_EN ); + +writel (MMIO_STATUS_GALOG_OVERFLOW_MASK , + iommu->mmio_base +MMIO_STATUS_OFFSET ); + +iommu_feature_enable (iommu,CONTROL_GAINT_EN ); +iommu_feature_enable (iommu,CONTROL_GALOG_EN ); +} +/* * This function resets the command buffer if the IOMMU stopped fetching * commands from it.
drivers/iommu/amd/iommu.c +8 -1
@@ -845,6 +845,7 @@ amd_iommu_set_pci_msi_domain(struct device *dev, struct amd_iommu *iommu) { } (MMIO_STATUS_EVT_OVERFLOW_INT_MASK | \MMIO_STATUS_EVT_INT_MASK | \MMIO_STATUS_PPR_INT_MASK | \ +MMIO_STATUS_GALOG_OVERFLOW_MASK | \ MMIO_STATUS_GALOG_INT_MASK)irqreturn_t amd_iommu_int_thread (int irq,void *data)
@@ -868,10 +869,16 @@ irqreturn_t amd_iommu_int_thread(int irq, void *data) }#ifdef CONFIG_IRQ_REMAP -if (status &MMIO_STATUS_GALOG_INT_MASK ) { +if (status & (MMIO_STATUS_GALOG_INT_MASK | +MMIO_STATUS_GALOG_OVERFLOW_MASK )) {pr_devel ("Processing IOMMU GA Log\n" );iommu_poll_ga_log (iommu); } + +if (status &MMIO_STATUS_GALOG_OVERFLOW_MASK ) { +pr_info_ratelimited ("IOMMU GA Log overflow\n" ); +amd_iommu_restart_ga_log (iommu); + }#endif if (status &MMIO_STATUS_EVT_OVERFLOW_INT_MASK ) {
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 3/19 scsi: target: iscsi: Fix hang in the iSCSI login code
In reply to Sasha LevinFrom: Maurizio Lombardi <[email protected]>
[ Upstream commit 13247018d68f21e7132924b9853f7e2c423588b6 ]
If the initiator suddenly stops sending data during a login while keeping the TCP connection open, the login_work won't be scheduled and will never release the login semaphore; concurrent login operations will therefore get stuck and fail.
The bug is due to the inability of the login timeout code to properly handle this particular case.
Fix the problem by replacing the old per-NP login timer with a new per-connection timer.
The timer is started when an initiator connects to the target; if it expires, it sends a SIGINT signal to the thread pointed at by the conn->login_kworker pointer.
conn->login_kworker is set by calling the iscsit_set_login_timer_kworker() helper, initially it will point to the np thread; When the login operation's control is in the process of being passed from the NP-thread to login_work, the conn->login_worker pointer is set to NULL. Finally, login_kworker will be changed to point to the worker thread executing the login_work job.
If conn->login_kworker is NULL when the timer expires, it means that the login operation hasn't been completed yet but login_work isn't running, in this case the timer will mark the login process as failed and will schedule login_work so the latter will be forced to free the resources it holds.
--- drivers/target/iscsi/iscsi_target.c | 2 - drivers/target/iscsi/iscsi_target_login.c | 63 ++------------------ drivers/target/iscsi/iscsi_target_nego.c | 70 +++++++++++++---------- drivers/target/iscsi/iscsi_target_util.c | 51 +++++++++++++++++ drivers/target/iscsi/iscsi_target_util.h | 4 ++ include/target/iscsi/iscsi_target_core.h | 6 +- 6 files changed, 103 insertions(+), 93 deletions(-)
drivers/target/iscsi/iscsi_target.c +0 -2
@@ -363,8 +363,6 @@ struct iscsi_np *iscsit_add_np(init_completion (&np->np_restart_comp);INIT_LIST_HEAD (&np->np_list); -timer_setup (&np->np_login_timer, iscsi_handle_login_thread_timeout,0 ); - ret =iscsi_target_setup_login_socket (np, sockaddr);if (ret !=0 ) {kfree (np);
drivers/target/iscsi/iscsi_target_login.c +5 -58
103 lines not on this page · raw message
drivers/target/iscsi/iscsi_target_nego.c +39 -31
122 lines not on this page · raw message
drivers/target/iscsi/iscsi_target_util.c +51 -0
57 lines not on this page · raw message
drivers/target/iscsi/iscsi_target_util.h +4 -0
@@ -56,6 +56,10 @@ extern void iscsit_handle_nopin_timeout(struct timer_list *t);extern void __iscsit_start_nopin_timer (struct iscsit_conn *);extern void iscsit_start_nopin_timer (struct iscsit_conn *);extern void iscsit_stop_nopin_timer (struct iscsit_conn *); +extern void iscsit_login_timeout (struct timer_list *t); +extern void iscsit_start_login_timer (struct iscsit_conn *,struct task_struct *kthr); +extern void iscsit_stop_login_timer (struct iscsit_conn *); +extern int iscsit_set_login_timer_kworker (struct iscsit_conn *,struct task_struct *kthr);extern int iscsit_send_tx_data (struct iscsit_cmd *,struct iscsit_conn *,int );extern int iscsit_fe_sendpage_sg (struct iscsit_cmd *,struct iscsit_conn *);extern int iscsit_tx_login_rsp (struct iscsit_conn *,u8 ,u8 );
include/target/iscsi/iscsi_target_core.h +4 -2
@@ -562,12 +562,14 @@ struct iscsit_conn {#define LOGIN_FLAGS_READ_ACTIVE 2#define LOGIN_FLAGS_WRITE_ACTIVE 3#define LOGIN_FLAGS_CLOSED 4 +#define LOGIN_FLAGS_WORKER_RUNNING 5unsigned long login_flags;struct delayed_work login_work;struct iscsi_login *login;struct timer_list nopin_timer;struct timer_list nopin_response_timer;struct timer_list transport_timer; +struct timer_list login_timer;struct task_struct *login_kworker;/* Spinlock used for add/deleting cmd's from conn_cmd_list */ spinlock_t cmd_lock;
@@ -576,6 +578,8 @@ struct iscsit_conn {spinlock_t nopin_timer_lock;spinlock_t response_queue_lock;spinlock_t state_lock; +spinlock_t login_timer_lock; +spinlock_t login_worker_lock;/* libcrypto RX and TX contexts for crc32c */ struct ahash_request *conn_rx_hash;struct ahash_request *conn_tx_hash;
@@ -792,7 +796,6 @@ struct iscsi_np {enum np_thread_state_table np_thread_state;bool enabled;atomic_t np_reset_count; -enum iscsi_timer_flags_table np_login_timer_flags;u32 np_exports;enum np_flags_table np_flags;spinlock_t np_thread_lock;
@@ -800,7 +803,6 @@ struct iscsi_np {struct socket *np_socket;struct sockaddr_storage np_sockaddr;struct task_struct *np_thread; -struct timer_list np_login_timer;void *np_context;struct iscsit_transport *np_transport;struct list_head np_list;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 4/19 scsi: target: iscsi: Remove unused transport_timer
In reply to Sasha LevinFrom: Maurizio Lombardi <[email protected]>
[ Upstream commit 98a8c2bf938a5973716f280da618077a3d255976 ]
--- include/target/iscsi/iscsi_target_core.h | 1 - 1 file changed, 1 deletion(-)
include/target/iscsi/iscsi_target_core.h +0 -1
@@ -568,7 +568,6 @@ struct iscsit_conn {struct iscsi_login *login;struct timer_list nopin_timer;struct timer_list nopin_response_timer; -struct timer_list transport_timer;struct timer_list login_timer;struct task_struct *login_kworker;/* Spinlock used for add/deleting cmd's from conn_cmd_list */
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 5/19 scsi: target: iscsi: Prevent login threads from racing between each other
In reply to Sasha LevinFrom: Maurizio Lombardi <[email protected]>
[ Upstream commit 2a737d3b8c792400118d6cf94958f559de9c5e59 ]
The tpg->np_login_sem is a semaphore that is used to serialize the login process when multiple login threads run concurrently against the same target portal group.
The iscsi_target_locate_portal() function finds the tpg, calls iscsit_access_np() against the np_login_sem semaphore and saves the tpg pointer in conn->tpg;
If iscsi_target_locate_portal() fails, the caller will check for the conn->tpg pointer and, if it's not NULL, then it will assume that iscsi_target_locate_portal() called iscsit_access_np() on the semaphore.
Make sure that conn->tpg gets initialized only if iscsit_access_np() was successful, otherwise iscsit_deaccess_np() may end up being called against a semaphore we never took, allowing more than one thread to access the same tpg.
--- drivers/target/iscsi/iscsi_target_nego.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/target/iscsi/iscsi_target_nego.c +3 -1
@@ -1122,6 +1122,7 @@ int iscsi_target_locate_portal(iscsi_target_set_sock_callbacks (conn); login->np = np; + conn->tpg =NULL ; login_req = (struct iscsi_login_req *) login->req; payload_length =ntoh24 (login_req->dlength);
@@ -1189,7 +1190,6 @@ int iscsi_target_locate_portal(*/ sessiontype =strncmp (s_buf,DISCOVERY ,9 );if (!sessiontype) { - conn->tpg = iscsit_global->discovery_tpg;if (!login->leading_connection) goto get_target;
@@ -1206,9 +1206,11 @@ int iscsi_target_locate_portal(* Serialize access across the discovery struct iscsi_portal_group to * process login attempt. */ + conn->tpg = iscsit_global->discovery_tpg;if (iscsit_access_np (np, conn->tpg) <0 ) {iscsit_tx_login_rsp (conn,ISCSI_STATUS_CLS_TARGET_ERR ,ISCSI_LOGIN_STATUS_SVC_UNAVAILABLE ); + conn->tpg =NULL ; ret =-1 ; goto out; }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 6/19 HID: google: add jewel USB id
In reply to Sasha LevinFrom: Sung-Chi Li <[email protected]>
[ Upstream commit ed84c4517a5bc536e8572a01dfa11bc22a280d06 ]
Add 1 additional hammer-like device.
--- drivers/hid/hid-google-hammer.c | 2 ++ drivers/hid/hid-ids.h | 1 + 2 files changed, 3 insertions(+)
drivers/hid/hid-google-hammer.c +2 -0
@@ -586,6 +586,8 @@ static const struct hid_device_id hammer_devices[] = { USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_EEL) }, {HID_DEVICE (BUS_USB ,HID_GROUP_GENERIC , USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_HAMMER) }, + { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, + USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_JEWEL) }, { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_MAGNEMITE) }, { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
drivers/hid/hid-ids.h +1 -0
@@ -529,6 +529,7 @@#define USB_DEVICE_ID_GOOGLE_MOONBALL 0x5044#define USB_DEVICE_ID_GOOGLE_DON 0x5050#define USB_DEVICE_ID_GOOGLE_EEL 0x5057 +#define USB_DEVICE_ID_GOOGLE_JEWEL 0x5061#define USB_VENDOR_ID_GOTOP 0x08f2#define USB_DEVICE_ID_SUPER_Q2 0x007f
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 7/19 HID: wacom: Add error check to wacom_parse_and_register()
In reply to Sasha LevinFrom: Denis Arefev <[email protected]>
[ Upstream commit 16a9c24f24fbe4564284eb575b18cc20586b9270 ]
Added a variable check and
transition in case of an error
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/hid/wacom_sys.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/hid/wacom_sys.c +6 -1
@@ -2417,8 +2417,13 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless) goto fail_quirks; } -if (features->device_type &WACOM_DEVICETYPE_WL_MONITOR ) +if (features->device_type &WACOM_DEVICETYPE_WL_MONITOR ) { error =hid_hw_open (hdev); +if (error) { +hid_err (hdev,"hw open failed\n" ); + goto fail_quirks; + } + }wacom_set_shared_values (wacom_wac);devres_close_group (&hdev->dev, wacom);
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 8/19 arm64: Add missing Set/Way CMO encodings
In reply to Sasha LevinFrom: Marc Zyngier <[email protected]>
[ Upstream commit 8d0f019e4c4f2ee2de81efd9bf1c27e9fb3c0460 ]
Add the missing Set/Way CMOs that apply to tagged memory.
--- arch/arm64/include/asm/sysreg.h | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/include/asm/sysreg.h +6 -0
@@ -115,8 +115,14 @@#define SB_BARRIER_INSN __SYS_BARRIER_INSN(0, 7, 31)#define SYS_DC_ISW sys_insn(1, 0, 7, 6, 2) +#define SYS_DC_IGSW sys_insn(1, 0, 7, 6, 4) +#define SYS_DC_IGDSW sys_insn(1, 0, 7, 6, 6)#define SYS_DC_CSW sys_insn(1, 0, 7, 10, 2) +#define SYS_DC_CGSW sys_insn(1, 0, 7, 10, 4) +#define SYS_DC_CGDSW sys_insn(1, 0, 7, 10, 6)#define SYS_DC_CISW sys_insn(1, 0, 7, 14, 2) +#define SYS_DC_CIGSW sys_insn(1, 0, 7, 14, 4) +#define SYS_DC_CIGDSW sys_insn(1, 0, 7, 14, 6)/* * Automatically generated definitions for system registers, the
Signature · 7 lines
2.39.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 9/19 smb3: missing null check in SMB2_change_notify
In reply to Sasha LevinFrom: Steve French <[email protected]>
[ Upstream commit b535cc796a4b4942cd189652588e8d37c1f5925a ]
If plen is null when passed in, we only checked for null in one of the two places where it could be used. Although plen is always valid (not null) for current callers of the SMB2_change_notify function, this change makes it more consistent.
--- fs/cifs/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/smb2pdu.c +1 -1
@@ -3777,7 +3777,7 @@ SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,if (*out_data ==NULL ) { rc = -ENOMEM ; goto cnotify_exit; - }else + }else if (plen) *plen =le32_to_cpu (smb_rsp->OutputBufferLength); }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 10/19 media: cec: core: disable adapter in cec_devnode_unregister
In reply to Sasha LevinFrom: Hans Verkuil <[email protected]>
[ Upstream commit fe4526d99e2e06b08bb80316c3a596ea6a807b75 ]
Explicitly disable the CEC adapter in cec_devnode_unregister()
Usually this does not really do anything important, but for drivers that use the CEC pin framework this is needed to properly stop the hrtimer. Without this a crash would happen when such a driver is unloaded with rmmod.
--- drivers/media/cec/core/cec-adap.c | 5 ++++- drivers/media/cec/core/cec-core.c | 2 ++ drivers/media/cec/core/cec-priv.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-)
drivers/media/cec/core/cec-adap.c +4 -1
@@ -1582,7 +1582,7 @@ static void cec_claim_log_addrs(struct cec_adapter *adap, bool block)* * This function is called with adap->lock held. */ -static int cec_adap_enable (struct cec_adapter *adap) +int cec_adap_enable (struct cec_adapter *adap) {bool enable;int ret =0 ;
@@ -1592,6 +1592,9 @@ static int cec_adap_enable(struct cec_adapter *adap)if (adap->needs_hpd) enable = enable && adap->phys_addr !=CEC_PHYS_ADDR_INVALID ; +if (adap->devnode.unregistered) + enable = false; +if (enable == adap->is_enabled)return 0 ;
drivers/media/cec/core/cec-core.c +2 -0
@@ -191,6 +191,8 @@ static void cec_devnode_unregister(struct cec_adapter *adap)mutex_lock (&adap->lock);__cec_s_phys_addr (adap,CEC_PHYS_ADDR_INVALID , false);__cec_s_log_addrs (adap,NULL , false); +// Disable the adapter (since adap->devnode.unregistered is true) +cec_adap_enable (adap);mutex_unlock (&adap->lock);cdev_device_del (&devnode->cdev, &devnode->dev);
drivers/media/cec/core/cec-priv.h +1 -0
@@ -47,6 +47,7 @@ int cec_monitor_pin_cnt_inc(struct cec_adapter *adap);void cec_monitor_pin_cnt_dec (struct cec_adapter *adap);int cec_adap_status (struct seq_file *file,void *priv);int cec_thread_func (void *_adap); +int cec_adap_enable (struct cec_adapter *adap);void __cec_s_phys_addr (struct cec_adapter *adap,u16 phys_addr,bool block);int __cec_s_log_addrs (struct cec_adapter *adap,struct cec_log_addrs *log_addrs,bool block);
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 11/19 media: cec: core: don't set last_initiator if tx in progress
In reply to Sasha LevinFrom: Hans Verkuil <[email protected]>
[ Upstream commit 73af6c7511038249cad3d5f3b44bf8d78ac0f499 ]
When a message was received the last_initiator is set to 0xff. This will force the signal free time for the next transmit to that for a new initiator. However, if a new transmit is already in progress, then don't set last_initiator, since that's the initiator of the current transmit. Overwriting this would cause the signal free time of a following transmit to be that of the new initiator instead of a next transmit.
--- drivers/media/cec/core/cec-adap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/cec/core/cec-adap.c +2 -1
@@ -1090,7 +1090,8 @@ void cec_received_msg_ts(struct cec_adapter *adap,mutex_lock (&adap->lock);dprintk (2 ,"%s: %*ph\n" , __func__, msg->len, msg->msg); - adap->last_initiator =0xff ; +if (!adap->transmit_in_progress) + adap->last_initiator =0xff ;/* Check if this message was for us (directed or broadcast). */ if (!cec_msg_is_broadcast (msg))
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 12/19 nfcsim.c: Fix error checking for debugfs_create_dir
In reply to Sasha LevinFrom: Osama Muhammad <[email protected]>
[ Upstream commit 9b9e46aa07273ceb96866b2e812b46f1ee0b8d2f ]
This patch fixes the error checking in nfcsim.c. The DebugFS kernel API is developed in
a way that the caller can safely ignore the errors that occur during the creation of DebugFS nodes.
--- drivers/nfc/nfcsim.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/nfc/nfcsim.c +0 -4
@@ -336,10 +336,6 @@ static struct dentry *nfcsim_debugfs_root;static void nfcsim_debugfs_init (void ) { nfcsim_debugfs_root =debugfs_create_dir ("nfcsim" ,NULL ); - -if (!nfcsim_debugfs_root) -pr_err ("Could not create debugfs entry\n" ); - }static void nfcsim_debugfs_remove (void )
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 13/19 btrfs: fix an uninitialized variable warning in btrfs_log_inode
In reply to Sasha LevinFrom: Shida Zhang <[email protected]>
[ Upstream commit 8fd9f4232d8152c650fd15127f533a0f6d0a4b2b ]
This fixes the following warning reported by gcc 10.2.1 under x86_64:
../fs/btrfs/tree-log.c: In function ‘btrfs_log_inode’:../fs/btrfs/tree-log.c:6211:9: error: ‘last_range_start’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
6211 | ret = insert_dir_log_key(trans, log, path, key.objectid,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6212 | first_dir_index, last_dir_index);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../fs/btrfs/tree-log.c:6161:6: note: ‘last_range_start’ was declared here
6161 | u64 last_range_start;
| ^~~~~~~~~~~~~~~~This might be a false positive fixed in later compiler versions but we want to have it fixed.
--- fs/btrfs/tree-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/tree-log.c +1 -1
@@ -6163,7 +6163,7 @@ static int log_delayed_deletions_incremental(struct btrfs_trans_handle *trans, {struct btrfs_root *log = inode->root->log_root;const struct btrfs_delayed_item *curr; -u64 last_range_start; +u64 last_range_start =0 ;u64 last_range_end =0 ;struct btrfs_key key;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 14/19 usb: gadget: udc: fix NULL dereference in remove()
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit 016da9c65fec9f0e78c4909ed9a0f2d567af6775 ]
The "udc" pointer was never set in the probe() function so it will lead to a NULL dereference in udc_pci_remove() when we do:
usb_del_gadget_udc(&udc->gadget);
--- drivers/usb/gadget/udc/amd5536udc_pci.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/gadget/udc/amd5536udc_pci.c +3 -0
@@ -170,6 +170,9 @@ static int udc_pci_probe( retval = -ENODEV ; goto err_probe; } + + udc = dev; +return 0 ; err_probe:
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 15/19 nvme: fix miss command type check
In reply to Sasha LevinFrom: "min15.li" <[email protected]>
[ Upstream commit 31a5978243d24d77be4bacca56c78a0fbc43b00d ]
In the function nvme_passthru_end(), only the value of the command opcode is checked, without checking the command type (IO command or Admin command). When we send a Dataset Management command (The opcode of the Dataset Management command is the same as the Set Feature command), kernel thinks it is a set feature command, then sets the controller's keep alive interval, and calls nvme_keep_alive_work().
--- drivers/nvme/host/core.c | 4 +++- drivers/nvme/host/ioctl.c | 2 +- drivers/nvme/host/nvme.h | 2 +- drivers/nvme/target/passthru.c | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-)
drivers/nvme/host/core.c +3 -1
@@ -1115,7 +1115,7 @@ u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u8 opcode) }EXPORT_SYMBOL_NS_GPL (nvme_passthru_start,NVME_TARGET_PASSTHRU ); -void nvme_passthru_end (struct nvme_ctrl *ctrl,u32 effects, +void nvme_passthru_end (struct nvme_ctrl *ctrl,struct nvme_ns *ns,u32 effects,struct nvme_command *cmd,int status) {if (effects &NVME_CMD_EFFECTS_CSE_MASK ) {
@@ -1132,6 +1132,8 @@ void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects,nvme_queue_scan (ctrl);flush_work (&ctrl->scan_work); } +if (ns) +return ;switch (cmd->common.opcode) {case nvme_admin_set_features:
drivers/nvme/host/ioctl.c +1 -1
@@ -254,7 +254,7 @@ static int nvme_submit_user_cmd(struct request_queue *q,blk_mq_free_request (req);if (effects) -nvme_passthru_end (ctrl, effects, cmd, ret); +nvme_passthru_end (ctrl, ns, effects, cmd, ret);return ret; }
drivers/nvme/host/nvme.h +1 -1
@@ -1072,7 +1072,7 @@ u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u8 opcode);u32 nvme_passthru_start (struct nvme_ctrl *ctrl,struct nvme_ns *ns,u8 opcode);int nvme_execute_rq (struct request *rq,bool at_head); -void nvme_passthru_end (struct nvme_ctrl *ctrl,u32 effects, +void nvme_passthru_end (struct nvme_ctrl *ctrl,struct nvme_ns *ns,u32 effects,struct nvme_command *cmd,int status);struct nvme_ctrl *nvme_ctrl_from_file (struct file *file);struct nvme_ns *nvme_find_get_ns (struct nvme_ctrl *ctrl,unsigned nsid);
drivers/nvme/target/passthru.c +1 -1
@@ -243,7 +243,7 @@ static void nvmet_passthru_execute_cmd_work(struct work_struct *w)blk_mq_free_request (rq);if (effects) -nvme_passthru_end (ctrl, effects, req->cmd, status); +nvme_passthru_end (ctrl, ns, effects, req->cmd, status); } static enum rq_end_io_ret nvmet_passthru_req_done(struct request *rq,
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 16/19 nvme: double KA polling frequency to avoid KATO with TBKAS on
In reply to Sasha LevinFrom: Uday Shankar <[email protected]>
[ Upstream commit ea4d453b9ec9ea279c39744cd0ecb47ef48ede35 ]
With TBKAS on, the completion of one command can defer sending a keep alive for up to twice the delay between successive runs of nvme_keep_alive_work. The current delay of KATO / 2 thus makes it possible for one command to defer sending a keep alive for up to KATO, which can result in the controller detecting a KATO. The following trace demonstrates the issue, taking KATO = 8 for simplicity:
1. t = 0: run nvme_keep_alive_work, no keep-alive sent
2. t = ε: I/O completion seen, set comp_seen = true
3. t = 4: run nvme_keep_alive_work, see comp_seen == true, skip sending keep-alive, set comp_seen = false
4. t = 8: run nvme_keep_alive_work, see comp_seen == false, send a keep-alive command.
Here, there is a delay of 8 - ε between receiving a command completion and sending the next command. With ε small, the controller is likely to detect a keep alive timeout.
Fix this by running nvme_keep_alive_work with a delay of KATO / 4 whenever TBKAS is on. Going through the above trace now gives us a worst-case delay of 4 - ε, which is in line with the recommendation of sending a command every KATO / 2 in the NVMe specification.
--- drivers/nvme/host/core.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +17 -1
@@ -1163,9 +1163,25 @@ EXPORT_SYMBOL_NS_GPL(nvme_passthru_end, NVME_TARGET_PASSTHRU);* The host should send Keep Alive commands at half of the Keep Alive Timeout * accounting for transport roundtrip times [..]. */ +static unsigned long nvme_keep_alive_work_period (struct nvme_ctrl *ctrl) +{ +unsigned long delay = ctrl->kato *HZ /2 ; + +/* +* When using Traffic Based Keep Alive, we need to run +* nvme_keep_alive_work at twice the normal frequency, as one +* command completion can postpone sending a keep alive command +* by up to twice the delay between runs. +*/ +if (ctrl->ctratt &NVME_CTRL_ATTR_TBKAS ) + delay /=2 ; +return delay; +} +static void nvme_queue_keep_alive_work (struct nvme_ctrl *ctrl) { -queue_delayed_work (nvme_wq, &ctrl->ka_work, ctrl->kato *HZ /2 ); +queue_delayed_work (nvme_wq, &ctrl->ka_work, +nvme_keep_alive_work_period (ctrl)); } static enum rq_end_io_ret nvme_keep_alive_end_io(struct request *rq,
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 17/19 nvme: check IO start time when deciding to defer KA
In reply to Sasha LevinFrom: Uday Shankar <[email protected]>
[ Upstream commit 774a9636514764ddc0d072ae0d1d1c01a47e6ddd ]
When a command completes, we set a flag which will skip sending a keep alive at the next run of nvme_keep_alive_work when TBKAS is on. However, if the command was submitted long ago, it's possible that the controller may have also restarted its keep alive timer (as a result of receiving the command) long ago. The following trace demonstrates the issue, assuming TBKAS is on and KATO = 8 for simplicity:
1. t = 0: submit I/O commands A, B, C, D, E
2. t = 0.5: commands A, B, C, D, E reach controller, restart its keep alive timer
3. t = 1: A completes
4. t = 2: run nvme_keep_alive_work, see recent completion, do nothing
5. t = 3: B completes
6. t = 4: run nvme_keep_alive_work, see recent completion, do nothing
7. t = 5: C completes
8. t = 6: run nvme_keep_alive_work, see recent completion, do nothing
9. t = 7: D completes
10. t = 8: run nvme_keep_alive_work, see recent completion, do nothing
11. t = 9: E completes
At this point, 8.5 seconds have passed without restarting the controller's keep alive timer, so the controller will detect a keep alive timeout.
Fix this by checking the IO start time when deciding to defer sending a keep alive command. Only set comp_seen if the command started after the most recent run of nvme_keep_alive_work. With this change, the completions of B, C, and D will not set comp_seen and the run of nvme_keep_alive_work at t = 4 will send a keep alive.
--- drivers/nvme/host/core.c | 14 +++++++++++++- drivers/nvme/host/nvme.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +13 -1
@@ -397,7 +397,16 @@ void nvme_complete_rq(struct request *req)trace_nvme_complete_rq (req);nvme_cleanup_cmd (req); -if (ctrl->kas) +/* +* Completions of long-running commands should not be able to +* defer sending of periodic keep alives, since the controller +* may have completed processing such commands a long time ago +* (arbitrarily close to command submission time). +* req->deadline - req->timeout is the command submission time +* in jiffies. +*/ +if (ctrl->kas && + req->deadline - req->timeout >= ctrl->ka_last_check_time) ctrl->comp_seen = true;switch (nvme_decide_disposition (req)) {
@@ -1200,6 +1209,7 @@ static enum rq_end_io_ret nvme_keep_alive_end_io(struct request *rq,return RQ_END_IO_NONE ; } + ctrl->ka_last_check_time = jiffies; ctrl->comp_seen = false;spin_lock_irqsave (&ctrl->lock, flags); if (ctrl->state == NVME_CTRL_LIVE ||
@@ -1218,6 +1228,8 @@ static void nvme_keep_alive_work(struct work_struct *work)bool comp_seen = ctrl->comp_seen;struct request *rq; + ctrl->ka_last_check_time = jiffies; +if ((ctrl->ctratt &NVME_CTRL_ATTR_TBKAS ) && comp_seen) {dev_dbg (ctrl->device,"reschedule traffic based keep-alive timer\n" );
drivers/nvme/host/nvme.h +1 -0
@@ -323,6 +323,7 @@ struct nvme_ctrl {struct delayed_work ka_work;struct delayed_work failfast_work;struct nvme_command ka_cmd; +unsigned long ka_last_check_time;struct work_struct fw_act_work;unsigned long events;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 18/19 ext4: enable the lazy init thread when remounting read/write
In reply to Sasha LevinFrom: Theodore Ts'o <[email protected]>
[ Upstream commit eb1f822c76beeaa76ab8b6737ab9dc9f9798408c ]
In commit a44be64bbecb ("ext4: don't clear SB_RDONLY when remounting r/w until quota is re-enabled") we defer clearing tyhe SB_RDONLY flag in struct super. However, we didn't defer when we checked sb_rdonly() to determine the lazy itable init thread should be enabled, with the next result that the lazy inode table initialization would not be properly started. This can cause generic/231 to fail in ext4's nojournal mode.
Fix this by moving when we decide to start or stop the lazy itable init thread to after we clear the SB_RDONLY flag when we are remounting the file system read/write.
Fixes a44be64bbecb ("ext4: don't clear SB_RDONLY when remounting r/w until...")
--- fs/ext4/super.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
fs/ext4/super.c +12 -12
@@ -6554,18 +6554,6 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb) } } -/* -* Reinitialize lazy itable initialization thread based on -* current settings -*/ -if (sb_rdonly (sb) || !test_opt (sb,INIT_INODE_TABLE )) -ext4_unregister_li_request (sb); -else { -ext4_group_t first_not_zeroed; - first_not_zeroed =ext4_has_uninit_itable (sb); -ext4_register_li_request (sb, first_not_zeroed); - } -/* * Handle creation of system zone data early because it can fail. * Releasing of existing data is done when we are sure remount will
@@ -6603,6 +6591,18 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb)if (enable_rw) sb->s_flags &= ~SB_RDONLY ; +/* +* Reinitialize lazy itable initialization thread based on +* current settings +*/ +if (sb_rdonly (sb) || !test_opt (sb,INIT_INODE_TABLE )) +ext4_unregister_li_request (sb); +else { +ext4_group_t first_not_zeroed; + first_not_zeroed =ext4_has_uninit_itable (sb); +ext4_register_li_request (sb, first_not_zeroed); + } +if (!ext4_has_feature_mmp (sb) ||sb_rdonly (sb))ext4_stop_mmpd (sbi);
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 19/19 nvme: improve handling of long keep alives
In reply to Sasha LevinFrom: Uday Shankar <[email protected]>
[ Upstream commit c7275ce6a5fd32ca9f5a6294ed89cf0523181af9 ]
Upon keep alive completion, nvme_keep_alive_work is scheduled with the same delay every time. If keep alive commands are completing slowly, this may cause a keep alive timeout. The following trace illustrates the issue, taking KATO = 8 and TBKAS off for simplicity:
1. t = 0: run nvme_keep_alive_work, send keep alive
2. t = ε: keep alive reaches controller, controller restarts its keep alive timer
3. t = 4: host receives keep alive completion, schedules nvme_keep_alive_work with delay 4
4. t = 8: run nvme_keep_alive_work, send keep alive
Here, a keep alive having RTT of 4 causes a delay of at least 8 - ε between the controller receiving successive keep alives. With ε small, the controller is likely to detect a keep alive timeout.
Fix this by calculating the RTT of the keep alive command, and adjusting the scheduling delay of the next keep alive work accordingly.
--- drivers/nvme/host/core.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +15 -1
@@ -1199,6 +1199,20 @@ static enum rq_end_io_ret nvme_keep_alive_end_io(struct request *rq,struct nvme_ctrl *ctrl = rq->end_io_data;unsigned long flags;bool startka = false; +unsigned long rtt = jiffies - (rq->deadline - rq->timeout); +unsigned long delay =nvme_keep_alive_work_period (ctrl); + +/* +* Subtract off the keepalive RTT so nvme_keep_alive_work runs +* at the desired frequency. +*/ +if (rtt <= delay) { + delay -= rtt; + }else { +dev_warn (ctrl->device,"long keepalive RTT (%u ms)\n" , +jiffies_to_msecs (rtt)); + delay =0 ; + }blk_mq_free_request (rq);
@@ -1217,7 +1231,7 @@ static enum rq_end_io_ret nvme_keep_alive_end_io(struct request *rq, startka = true;spin_unlock_irqrestore (&ctrl->lock, flags);if (startka) -nvme_queue_keep_alive_work (ctrl); +queue_delayed_work (nvme_wq, &ctrl->ka_work, delay);return RQ_END_IO_NONE ; }
Signature · 1 line
2.39.2