diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-16 07:06:26 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-16 07:06:26 +0200 |
commit | 72f02ba66bd83b54054da20eae550123de84da6f (patch) | |
tree | 96a8360400e040aa2e38e7352594dbbc485461db /drivers/scsi/libfc | |
parent | Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cl... (diff) | |
parent | scsi: core: use blk_mq_run_hw_queues in scsi_kick_queue (diff) | |
download | linux-72f02ba66bd83b54054da20eae550123de84da6f.tar.xz linux-72f02ba66bd83b54054da20eae550123de84da6f.zip |
Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI updates from James Bottomley:
"This is mostly updates to the usual drivers: mpt3sas, lpfc, qla2xxx,
hisi_sas, smartpqi, megaraid_sas, arcmsr.
In addition, with the continuing absence of Nic we have target updates
for tcmu and target core (all with reviews and acks).
The biggest observable change is going to be that we're (again) trying
to switch to mulitqueue as the default (a user can still override the
setting on the kernel command line).
Other major core stuff is the removal of the remaining Microchannel
drivers, an update of the internal timers and some reworks of
completion and result handling"
* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (203 commits)
scsi: core: use blk_mq_run_hw_queues in scsi_kick_queue
scsi: ufs: remove unnecessary query(DM) UPIU trace
scsi: qla2xxx: Fix issue reported by static checker for qla2x00_els_dcmd2_sp_done()
scsi: aacraid: Spelling fix in comment
scsi: mpt3sas: Fix calltrace observed while running IO & reset
scsi: aic94xx: fix an error code in aic94xx_init()
scsi: st: remove redundant pointer STbuffer
scsi: qla2xxx: Update driver version to 10.00.00.08-k
scsi: qla2xxx: Migrate NVME N2N handling into state machine
scsi: qla2xxx: Save frame payload size from ICB
scsi: qla2xxx: Fix stalled relogin
scsi: qla2xxx: Fix race between switch cmd completion and timeout
scsi: qla2xxx: Fix Management Server NPort handle reservation logic
scsi: qla2xxx: Flush mailbox commands on chip reset
scsi: qla2xxx: Fix unintended Logout
scsi: qla2xxx: Fix session state stuck in Get Port DB
scsi: qla2xxx: Fix redundant fc_rport registration
scsi: qla2xxx: Silent erroneous message
scsi: qla2xxx: Prevent sysfs access when chip is down
scsi: qla2xxx: Add longer window for chip reset
...
Diffstat (limited to 'drivers/scsi/libfc')
-rw-r--r-- | drivers/scsi/libfc/fc_disc.c | 47 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_lport.c | 108 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_rport.c | 100 |
3 files changed, 107 insertions, 148 deletions
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c index 3f3569ec5ce3..f969a71348ef 100644 --- a/drivers/scsi/libfc/fc_disc.c +++ b/drivers/scsi/libfc/fc_disc.c @@ -59,34 +59,25 @@ static void fc_disc_restart(struct fc_disc *); /** * fc_disc_stop_rports() - Delete all the remote ports associated with the lport * @disc: The discovery job to stop remote ports on - * - * Locking Note: This function expects that the lport mutex is locked before - * calling it. */ static void fc_disc_stop_rports(struct fc_disc *disc) { - struct fc_lport *lport; struct fc_rport_priv *rdata; - lport = fc_disc_lport(disc); + lockdep_assert_held(&disc->disc_mutex); - rcu_read_lock(); - list_for_each_entry_rcu(rdata, &disc->rports, peers) { + list_for_each_entry(rdata, &disc->rports, peers) { if (kref_get_unless_zero(&rdata->kref)) { fc_rport_logoff(rdata); kref_put(&rdata->kref, fc_rport_destroy); } } - rcu_read_unlock(); } /** * fc_disc_recv_rscn_req() - Handle Registered State Change Notification (RSCN) * @disc: The discovery object to which the RSCN applies * @fp: The RSCN frame - * - * Locking Note: This function expects that the disc_mutex is locked - * before it is called. */ static void fc_disc_recv_rscn_req(struct fc_disc *disc, struct fc_frame *fp) { @@ -101,6 +92,8 @@ static void fc_disc_recv_rscn_req(struct fc_disc *disc, struct fc_frame *fp) LIST_HEAD(disc_ports); struct fc_disc_port *dp, *next; + lockdep_assert_held(&disc->disc_mutex); + lport = fc_disc_lport(disc); FC_DISC_DBG(disc, "Received an RSCN event\n"); @@ -220,12 +213,11 @@ static void fc_disc_recv_req(struct fc_lport *lport, struct fc_frame *fp) /** * fc_disc_restart() - Restart discovery * @disc: The discovery object to be restarted - * - * Locking Note: This function expects that the disc mutex - * is already locked. */ static void fc_disc_restart(struct fc_disc *disc) { + lockdep_assert_held(&disc->disc_mutex); + if (!disc->disc_callback) return; @@ -271,16 +263,13 @@ static void fc_disc_start(void (*disc_callback)(struct fc_lport *, * fc_disc_done() - Discovery has been completed * @disc: The discovery context * @event: The discovery completion status - * - * Locking Note: This function expects that the disc mutex is locked before - * it is called. The discovery callback is then made with the lock released, - * and the lock is re-taken before returning from this function */ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event) { struct fc_lport *lport = fc_disc_lport(disc); struct fc_rport_priv *rdata; + lockdep_assert_held(&disc->disc_mutex); FC_DISC_DBG(disc, "Discovery complete\n"); disc->pending = 0; @@ -294,9 +283,11 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event) * discovery, reverify or log them in. Otherwise, log them out. * Skip ports which were never discovered. These are the dNS port * and ports which were created by PLOGI. + * + * We don't need to use the _rcu variant here as the rport list + * is protected by the disc mutex which is already held on entry. */ - rcu_read_lock(); - list_for_each_entry_rcu(rdata, &disc->rports, peers) { + list_for_each_entry(rdata, &disc->rports, peers) { if (!kref_get_unless_zero(&rdata->kref)) continue; if (rdata->disc_id) { @@ -307,7 +298,6 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event) } kref_put(&rdata->kref, fc_rport_destroy); } - rcu_read_unlock(); mutex_unlock(&disc->disc_mutex); disc->disc_callback(lport, event); mutex_lock(&disc->disc_mutex); @@ -360,15 +350,14 @@ static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp) /** * fc_disc_gpn_ft_req() - Send Get Port Names by FC-4 type (GPN_FT) request * @lport: The discovery context - * - * Locking Note: This function expects that the disc_mutex is locked - * before it is called. */ static void fc_disc_gpn_ft_req(struct fc_disc *disc) { struct fc_frame *fp; struct fc_lport *lport = fc_disc_lport(disc); + lockdep_assert_held(&disc->disc_mutex); + WARN_ON(!fc_lport_test_ready(lport)); disc->pending = 1; @@ -658,8 +647,6 @@ out: * @lport: The local port to initiate discovery on * @rdata: remote port private data * - * Locking Note: This function expects that the disc_mutex is locked - * before it is called. * On failure, an error code is returned. */ static int fc_disc_gpn_id_req(struct fc_lport *lport, @@ -667,6 +654,7 @@ static int fc_disc_gpn_id_req(struct fc_lport *lport, { struct fc_frame *fp; + lockdep_assert_held(&lport->disc.disc_mutex); fp = fc_frame_alloc(lport, sizeof(struct fc_ct_hdr) + sizeof(struct fc_ns_fid)); if (!fp) @@ -683,14 +671,13 @@ static int fc_disc_gpn_id_req(struct fc_lport *lport, * fc_disc_single() - Discover the directory information for a single target * @lport: The local port the remote port is associated with * @dp: The port to rediscover - * - * Locking Note: This function expects that the disc_mutex is locked - * before it is called. */ static int fc_disc_single(struct fc_lport *lport, struct fc_disc_port *dp) { struct fc_rport_priv *rdata; + lockdep_assert_held(&lport->disc.disc_mutex); + rdata = fc_rport_create(lport, dp->port_id); if (!rdata) return -ENOMEM; @@ -708,7 +695,9 @@ static void fc_disc_stop(struct fc_lport *lport) if (disc->pending) cancel_delayed_work_sync(&disc->disc_work); + mutex_lock(&disc->disc_mutex); fc_disc_stop_rports(disc); + mutex_unlock(&disc->disc_mutex); } /** diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index 21be672679fb..be83590ed955 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c @@ -237,14 +237,13 @@ static const char *fc_lport_state(struct fc_lport *lport) * @remote_fid: The FID of the ptp rport * @remote_wwpn: The WWPN of the ptp rport * @remote_wwnn: The WWNN of the ptp rport - * - * Locking Note: The lport lock is expected to be held before calling - * this routine. */ static void fc_lport_ptp_setup(struct fc_lport *lport, u32 remote_fid, u64 remote_wwpn, u64 remote_wwnn) { + lockdep_assert_held(&lport->lp_mutex); + if (lport->ptp_rdata) { fc_rport_logoff(lport->ptp_rdata); kref_put(&lport->ptp_rdata->kref, fc_rport_destroy); @@ -403,12 +402,11 @@ static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type) * fc_lport_recv_rlir_req() - Handle received Registered Link Incident Report. * @lport: Fibre Channel local port receiving the RLIR * @fp: The RLIR request frame - * - * Locking Note: The lport lock is expected to be held before calling - * this function. */ static void fc_lport_recv_rlir_req(struct fc_lport *lport, struct fc_frame *fp) { + lockdep_assert_held(&lport->lp_mutex); + FC_LPORT_DBG(lport, "Received RLIR request while in state %s\n", fc_lport_state(lport)); @@ -420,9 +418,6 @@ static void fc_lport_recv_rlir_req(struct fc_lport *lport, struct fc_frame *fp) * fc_lport_recv_echo_req() - Handle received ECHO request * @lport: The local port receiving the ECHO * @fp: ECHO request frame - * - * Locking Note: The lport lock is expected to be held before calling - * this function. */ static void fc_lport_recv_echo_req(struct fc_lport *lport, struct fc_frame *in_fp) @@ -432,6 +427,8 @@ static void fc_lport_recv_echo_req(struct fc_lport *lport, void *pp; void *dp; + lockdep_assert_held(&lport->lp_mutex); + FC_LPORT_DBG(lport, "Received ECHO request while in state %s\n", fc_lport_state(lport)); @@ -456,9 +453,6 @@ static void fc_lport_recv_echo_req(struct fc_lport *lport, * fc_lport_recv_rnid_req() - Handle received Request Node ID data request * @lport: The local port receiving the RNID * @fp: The RNID request frame - * - * Locking Note: The lport lock is expected to be held before calling - * this function. */ static void fc_lport_recv_rnid_req(struct fc_lport *lport, struct fc_frame *in_fp) @@ -474,6 +468,8 @@ static void fc_lport_recv_rnid_req(struct fc_lport *lport, u8 fmt; size_t len; + lockdep_assert_held(&lport->lp_mutex); + FC_LPORT_DBG(lport, "Received RNID request while in state %s\n", fc_lport_state(lport)); @@ -515,12 +511,11 @@ static void fc_lport_recv_rnid_req(struct fc_lport *lport, * fc_lport_recv_logo_req() - Handle received fabric LOGO request * @lport: The local port receiving the LOGO * @fp: The LOGO request frame - * - * Locking Note: The lport lock is expected to be held before calling - * this function. */ static void fc_lport_recv_logo_req(struct fc_lport *lport, struct fc_frame *fp) { + lockdep_assert_held(&lport->lp_mutex); + fc_seq_els_rsp_send(fp, ELS_LS_ACC, NULL); fc_lport_enter_reset(lport); fc_frame_free(fp); @@ -553,11 +548,11 @@ EXPORT_SYMBOL(fc_fabric_login); /** * __fc_linkup() - Handler for transport linkup events * @lport: The lport whose link is up - * - * Locking: must be called with the lp_mutex held */ void __fc_linkup(struct fc_lport *lport) { + lockdep_assert_held(&lport->lp_mutex); + if (!lport->link_up) { lport->link_up = 1; @@ -584,11 +579,11 @@ EXPORT_SYMBOL(fc_linkup); /** * __fc_linkdown() - Handler for transport linkdown events * @lport: The lport whose link is down - * - * Locking: must be called with the lp_mutex held */ void __fc_linkdown(struct fc_lport *lport) { + lockdep_assert_held(&lport->lp_mutex); + if (lport->link_up) { lport->link_up = 0; fc_lport_enter_reset(lport); @@ -722,12 +717,11 @@ static void fc_lport_disc_callback(struct fc_lport *lport, /** * fc_rport_enter_ready() - Enter the ready state and start discovery * @lport: The local port that is ready - * - * Locking Note: The lport lock is expected to be held before calling - * this routine. */ static void fc_lport_enter_ready(struct fc_lport *lport) { + lockdep_assert_held(&lport->lp_mutex); + FC_LPORT_DBG(lport, "Entered READY from state %s\n", fc_lport_state(lport)); @@ -745,13 +739,12 @@ static void fc_lport_enter_ready(struct fc_lport *lport) * @lport: The local port which will have its Port ID set. * @port_id: The new port ID. * @fp: The frame containing the incoming request, or NULL. - * - * Locking Note: The lport lock is expected to be held before calling - * this function. */ static void fc_lport_set_port_id(struct fc_lport *lport, u32 port_id, struct fc_frame *fp) { + lockdep_assert_held(&lport->lp_mutex); + if (port_id) printk(KERN_INFO "host%d: Assigned Port ID %6.6x\n", lport->host->host_no, port_id); @@ -801,9 +794,6 @@ EXPORT_SYMBOL(fc_lport_set_local_id); * A received FLOGI request indicates a point-to-point connection. * Accept it with the common service parameters indicating our N port. * Set up to do a PLOGI if we have the higher-number WWPN. - * - * Locking Note: The lport lock is expected to be held before calling - * this function. */ static void fc_lport_recv_flogi_req(struct fc_lport *lport, struct fc_frame *rx_fp) @@ -816,6 +806,8 @@ static void fc_lport_recv_flogi_req(struct fc_lport *lport, u32 remote_fid; u32 local_fid; + lockdep_assert_held(&lport->lp_mutex); + FC_LPORT_DBG(lport, "Received FLOGI request while in state %s\n", fc_lport_state(lport)); @@ -1006,12 +998,11 @@ EXPORT_SYMBOL(fc_lport_reset); /** * fc_lport_reset_locked() - Reset the local port w/ the lport lock held * @lport: The local port to be reset - * - * Locking Note: The lport lock is expected to be held before calling - * this routine. */ static void fc_lport_reset_locked(struct fc_lport *lport) { + lockdep_assert_held(&lport->lp_mutex); + if (lport->dns_rdata) { fc_rport_logoff(lport->dns_rdata); lport->dns_rdata = NULL; @@ -1035,12 +1026,11 @@ static void fc_lport_reset_locked(struct fc_lport *lport) /** * fc_lport_enter_reset() - Reset the local port * @lport: The local port to be reset - * - * Locking Note: The lport lock is expected to be held before calling - * this routine. */ static void fc_lport_enter_reset(struct fc_lport *lport) { + lockdep_assert_held(&lport->lp_mutex); + FC_LPORT_DBG(lport, "Entered RESET state from %s state\n", fc_lport_state(lport)); @@ -1065,12 +1055,11 @@ static void fc_lport_enter_reset(struct fc_lport *lport) /** * fc_lport_enter_disabled() - Disable the local port * @lport: The local port to be reset - * - * Locking Note: The lport lock is expected to be held before calling - * this routine. */ static void fc_lport_enter_disabled(struct fc_lport *lport) { + lockdep_assert_held(&lport->lp_mutex); + FC_LPORT_DBG(lport, "Entered disabled state from %s state\n", fc_lport_state(lport)); @@ -1321,14 +1310,13 @@ err: /** * fc_lport_enter_scr() - Send a SCR (State Change Register) request * @lport: The local port to register for state changes - * - * Locking Note: The lport lock is expected to be held before calling - * this routine. */ static void fc_lport_enter_scr(struct fc_lport *lport) { struct fc_frame *fp; + lockdep_assert_held(&lport->lp_mutex); + FC_LPORT_DBG(lport, "Entered SCR state from %s state\n", fc_lport_state(lport)); @@ -1349,9 +1337,6 @@ static void fc_lport_enter_scr(struct fc_lport *lport) /** * fc_lport_enter_ns() - register some object with the name server * @lport: Fibre Channel local port to register - * - * Locking Note: The lport lock is expected to be held before calling - * this routine. */ static void fc_lport_enter_ns(struct fc_lport *lport, enum fc_lport_state state) { @@ -1360,6 +1345,8 @@ static void fc_lport_enter_ns(struct fc_lport *lport, enum fc_lport_state state) int size = sizeof(struct fc_ct_hdr); size_t len; + lockdep_assert_held(&lport->lp_mutex); + FC_LPORT_DBG(lport, "Entered %s state from %s state\n", fc_lport_state_names[state], fc_lport_state(lport)); @@ -1419,14 +1406,13 @@ static struct fc_rport_operations fc_lport_rport_ops = { /** * fc_rport_enter_dns() - Create a fc_rport for the name server * @lport: The local port requesting a remote port for the name server - * - * Locking Note: The lport lock is expected to be held before calling - * this routine. */ static void fc_lport_enter_dns(struct fc_lport *lport) { struct fc_rport_priv *rdata; + lockdep_assert_held(&lport->lp_mutex); + FC_LPORT_DBG(lport, "Entered DNS state from %s state\n", fc_lport_state(lport)); @@ -1449,9 +1435,6 @@ err: /** * fc_lport_enter_ms() - management server commands * @lport: Fibre Channel local port to register - * - * Locking Note: The lport lock is expected to be held before calling - * this routine. */ static void fc_lport_enter_ms(struct fc_lport *lport, enum fc_lport_state state) { @@ -1461,6 +1444,8 @@ static void fc_lport_enter_ms(struct fc_lport *lport, enum fc_lport_state state) size_t len; int numattrs; + lockdep_assert_held(&lport->lp_mutex); + FC_LPORT_DBG(lport, "Entered %s state from %s state\n", fc_lport_state_names[state], fc_lport_state(lport)); @@ -1536,14 +1521,13 @@ static void fc_lport_enter_ms(struct fc_lport *lport, enum fc_lport_state state) /** * fc_rport_enter_fdmi() - Create a fc_rport for the management server * @lport: The local port requesting a remote port for the management server - * - * Locking Note: The lport lock is expected to be held before calling - * this routine. */ static void fc_lport_enter_fdmi(struct fc_lport *lport) { struct fc_rport_priv *rdata; + lockdep_assert_held(&lport->lp_mutex); + FC_LPORT_DBG(lport, "Entered FDMI state from %s state\n", fc_lport_state(lport)); @@ -1668,15 +1652,14 @@ EXPORT_SYMBOL(fc_lport_logo_resp); /** * fc_rport_enter_logo() - Logout of the fabric * @lport: The local port to be logged out - * - * Locking Note: The lport lock is expected to be held before calling - * this routine. */ static void fc_lport_enter_logo(struct fc_lport *lport) { struct fc_frame *fp; struct fc_els_logo *logo; + lockdep_assert_held(&lport->lp_mutex); + FC_LPORT_DBG(lport, "Entered LOGO state from %s state\n", fc_lport_state(lport)); @@ -1811,14 +1794,13 @@ EXPORT_SYMBOL(fc_lport_flogi_resp); /** * fc_rport_enter_flogi() - Send a FLOGI request to the fabric manager * @lport: Fibre Channel local port to be logged in to the fabric - * - * Locking Note: The lport lock is expected to be held before calling - * this routine. */ static void fc_lport_enter_flogi(struct fc_lport *lport) { struct fc_frame *fp; + lockdep_assert_held(&lport->lp_mutex); + FC_LPORT_DBG(lport, "Entered FLOGI state from %s state\n", fc_lport_state(lport)); @@ -1962,9 +1944,6 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp, * @job: The BSG Passthrough job * @lport: The local port sending the request * @did: The destination port id - * - * Locking Note: The lport lock is expected to be held before calling - * this routine. */ static int fc_lport_els_request(struct bsg_job *job, struct fc_lport *lport, @@ -1976,6 +1955,8 @@ static int fc_lport_els_request(struct bsg_job *job, char *pp; int len; + lockdep_assert_held(&lport->lp_mutex); + fp = fc_frame_alloc(lport, job->request_payload.payload_len); if (!fp) return -ENOMEM; @@ -2023,9 +2004,6 @@ static int fc_lport_els_request(struct bsg_job *job, * @lport: The local port sending the request * @did: The destination FC-ID * @tov: The timeout period to wait for the response - * - * Locking Note: The lport lock is expected to be held before calling - * this routine. */ static int fc_lport_ct_request(struct bsg_job *job, struct fc_lport *lport, u32 did, u32 tov) @@ -2036,6 +2014,8 @@ static int fc_lport_ct_request(struct bsg_job *job, struct fc_ct_req *ct; size_t len; + lockdep_assert_held(&lport->lp_mutex); + fp = fc_frame_alloc(lport, sizeof(struct fc_ct_hdr) + job->request_payload.payload_len); if (!fp) diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c index 89b1f1af2fd4..372387a450df 100644 --- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c @@ -136,13 +136,13 @@ EXPORT_SYMBOL(fc_rport_lookup); * @ids: The identifiers for the new remote port * * The remote port will start in the INIT state. - * - * Locking note: must be called with the disc_mutex held. */ struct fc_rport_priv *fc_rport_create(struct fc_lport *lport, u32 port_id) { struct fc_rport_priv *rdata; + lockdep_assert_held(&lport->disc.disc_mutex); + rdata = fc_rport_lookup(lport, port_id); if (rdata) return rdata; @@ -184,6 +184,7 @@ void fc_rport_destroy(struct kref *kref) struct fc_rport_priv *rdata; rdata = container_of(kref, struct fc_rport_priv, kref); + WARN_ON(!list_empty(&rdata->peers)); kfree_rcu(rdata, rcu); } EXPORT_SYMBOL(fc_rport_destroy); @@ -245,12 +246,12 @@ static unsigned int fc_plogi_get_maxframe(struct fc_els_flogi *flp, * fc_rport_state_enter() - Change the state of a remote port * @rdata: The remote port whose state should change * @new: The new state - * - * Locking Note: Called with the rport lock held */ static void fc_rport_state_enter(struct fc_rport_priv *rdata, enum fc_rport_state new) { + lockdep_assert_held(&rdata->rp_mutex); + if (rdata->rp_state != new) rdata->retries = 0; rdata->rp_state = new; @@ -469,8 +470,6 @@ EXPORT_SYMBOL(fc_rport_login); * @rdata: The remote port to be deleted * @event: The event to report as the reason for deletion * - * Locking Note: Called with the rport lock held. - * * Allow state change into DELETE only once. * * Call queue_work only if there's no event already pending. @@ -483,6 +482,8 @@ EXPORT_SYMBOL(fc_rport_login); static void fc_rport_enter_delete(struct fc_rport_priv *rdata, enum fc_rport_event event) { + lockdep_assert_held(&rdata->rp_mutex); + if (rdata->rp_state == RPORT_ST_DELETE) return; @@ -546,13 +547,12 @@ EXPORT_SYMBOL(fc_rport_logoff); * fc_rport_enter_ready() - Transition to the RPORT_ST_READY state * @rdata: The remote port that is ready * - * Locking Note: The rport lock is expected to be held before calling - * this routine. - * * Reference counting: schedules workqueue, does not modify kref */ static void fc_rport_enter_ready(struct fc_rport_priv *rdata) { + lockdep_assert_held(&rdata->rp_mutex); + fc_rport_state_enter(rdata, RPORT_ST_READY); FC_RPORT_DBG(rdata, "Port is Ready\n"); @@ -615,15 +615,14 @@ static void fc_rport_timeout(struct work_struct *work) * @rdata: The remote port the error is happened on * @err: The error code * - * Locking Note: The rport lock is expected to be held before - * calling this routine - * * Reference counting: does not modify kref */ static void fc_rport_error(struct fc_rport_priv *rdata, int err) { struct fc_lport *lport = rdata->local_port; + lockdep_assert_held(&rdata->rp_mutex); + FC_RPORT_DBG(rdata, "Error %d in state %s, retries %d\n", -err, fc_rport_state(rdata), rdata->retries); @@ -662,15 +661,14 @@ static void fc_rport_error(struct fc_rport_priv *rdata, int err) * If the error was an exchange timeout retry immediately, * otherwise wait for E_D_TOV. * - * Locking Note: The rport lock is expected to be held before - * calling this routine - * * Reference counting: increments kref when scheduling retry_work */ static void fc_rport_error_retry(struct fc_rport_priv *rdata, int err) { unsigned long delay = msecs_to_jiffies(rdata->e_d_tov); + lockdep_assert_held(&rdata->rp_mutex); + /* make sure this isn't an FC_EX_CLOSED error, never retry those */ if (err == -FC_EX_CLOSED) goto out; @@ -822,9 +820,6 @@ bad: * fc_rport_enter_flogi() - Send a FLOGI request to the remote port for p-mp * @rdata: The remote port to send a FLOGI to * - * Locking Note: The rport lock is expected to be held before calling - * this routine. - * * Reference counting: increments kref when sending ELS */ static void fc_rport_enter_flogi(struct fc_rport_priv *rdata) @@ -832,6 +827,8 @@ static void fc_rport_enter_flogi(struct fc_rport_priv *rdata) struct fc_lport *lport = rdata->local_port; struct fc_frame *fp; + lockdep_assert_held(&rdata->rp_mutex); + if (!lport->point_to_multipoint) return fc_rport_enter_plogi(rdata); @@ -1071,9 +1068,6 @@ fc_rport_compatible_roles(struct fc_lport *lport, struct fc_rport_priv *rdata) * fc_rport_enter_plogi() - Send Port Login (PLOGI) request * @rdata: The remote port to send a PLOGI to * - * Locking Note: The rport lock is expected to be held before calling - * this routine. - * * Reference counting: increments kref when sending ELS */ static void fc_rport_enter_plogi(struct fc_rport_priv *rdata) @@ -1081,6 +1075,8 @@ static void fc_rport_enter_plogi(struct fc_rport_priv *rdata) struct fc_lport *lport = rdata->local_port; struct fc_frame *fp; + lockdep_assert_held(&rdata->rp_mutex); + if (!fc_rport_compatible_roles(lport, rdata)) { FC_RPORT_DBG(rdata, "PLOGI suppressed for incompatible role\n"); fc_rport_state_enter(rdata, RPORT_ST_PLOGI_WAIT); @@ -1232,9 +1228,6 @@ put: * fc_rport_enter_prli() - Send Process Login (PRLI) request * @rdata: The remote port to send the PRLI request to * - * Locking Note: The rport lock is expected to be held before calling - * this routine. - * * Reference counting: increments kref when sending ELS */ static void fc_rport_enter_prli(struct fc_rport_priv *rdata) @@ -1247,6 +1240,8 @@ static void fc_rport_enter_prli(struct fc_rport_priv *rdata) struct fc_frame *fp; struct fc4_prov *prov; + lockdep_assert_held(&rdata->rp_mutex); + /* * If the rport is one of the well known addresses * we skip PRLI and RTV and go straight to READY. @@ -1372,9 +1367,6 @@ put: * fc_rport_enter_rtv() - Send Request Timeout Value (RTV) request * @rdata: The remote port to send the RTV request to * - * Locking Note: The rport lock is expected to be held before calling - * this routine. - * * Reference counting: increments kref when sending ELS */ static void fc_rport_enter_rtv(struct fc_rport_priv *rdata) @@ -1382,6 +1374,8 @@ static void fc_rport_enter_rtv(struct fc_rport_priv *rdata) struct fc_frame *fp; struct fc_lport *lport = rdata->local_port; + lockdep_assert_held(&rdata->rp_mutex); + FC_RPORT_DBG(rdata, "Port entered RTV state from %s state\n", fc_rport_state(rdata)); @@ -1406,8 +1400,6 @@ static void fc_rport_enter_rtv(struct fc_rport_priv *rdata) * fc_rport_recv_rtv_req() - Handler for Read Timeout Value (RTV) requests * @rdata: The remote port that sent the RTV request * @in_fp: The RTV request frame - * - * Locking Note: Called with the lport and rport locks held. */ static void fc_rport_recv_rtv_req(struct fc_rport_priv *rdata, struct fc_frame *in_fp) @@ -1417,6 +1409,9 @@ static void fc_rport_recv_rtv_req(struct fc_rport_priv *rdata, struct fc_els_rtv_acc *rtv; struct fc_seq_els_data rjt_data; + lockdep_assert_held(&rdata->rp_mutex); + lockdep_assert_held(&lport->lp_mutex); + FC_RPORT_DBG(rdata, "Received RTV request\n"); fp = fc_frame_alloc(lport, sizeof(*rtv)); @@ -1460,9 +1455,6 @@ static void fc_rport_logo_resp(struct fc_seq *sp, struct fc_frame *fp, * fc_rport_enter_logo() - Send a logout (LOGO) request * @rdata: The remote port to send the LOGO request to * - * Locking Note: The rport lock is expected to be held before calling - * this routine. - * * Reference counting: increments kref when sending ELS */ static void fc_rport_enter_logo(struct fc_rport_priv *rdata) @@ -1470,6 +1462,8 @@ static void fc_rport_enter_logo(struct fc_rport_priv *rdata) struct fc_lport *lport = rdata->local_port; struct fc_frame *fp; + lockdep_assert_held(&rdata->rp_mutex); + FC_RPORT_DBG(rdata, "Port sending LOGO from %s state\n", fc_rport_state(rdata)); @@ -1548,9 +1542,6 @@ put: * fc_rport_enter_adisc() - Send Address Discover (ADISC) request * @rdata: The remote port to send the ADISC request to * - * Locking Note: The rport lock is expected to be held before calling - * this routine. - * * Reference counting: increments kref when sending ELS */ static void fc_rport_enter_adisc(struct fc_rport_priv *rdata) @@ -1558,6 +1549,8 @@ static void fc_rport_enter_adisc(struct fc_rport_priv *rdata) struct fc_lport *lport = rdata->local_port; struct fc_frame *fp; + lockdep_assert_held(&rdata->rp_mutex); + FC_RPORT_DBG(rdata, "sending ADISC from %s state\n", fc_rport_state(rdata)); @@ -1581,8 +1574,6 @@ static void fc_rport_enter_adisc(struct fc_rport_priv *rdata) * fc_rport_recv_adisc_req() - Handler for Address Discovery (ADISC) requests * @rdata: The remote port that sent the ADISC request * @in_fp: The ADISC request frame - * - * Locking Note: Called with the lport and rport locks held. */ static void fc_rport_recv_adisc_req(struct fc_rport_priv *rdata, struct fc_frame *in_fp) @@ -1592,6 +1583,9 @@ static void fc_rport_recv_adisc_req(struct fc_rport_priv *rdata, struct fc_els_adisc *adisc; struct fc_seq_els_data rjt_data; + lockdep_assert_held(&rdata->rp_mutex); + lockdep_assert_held(&lport->lp_mutex); + FC_RPORT_DBG(rdata, "Received ADISC request\n"); adisc = fc_frame_payload_get(in_fp, sizeof(*adisc)); @@ -1618,9 +1612,6 @@ drop: * fc_rport_recv_rls_req() - Handle received Read Link Status request * @rdata: The remote port that sent the RLS request * @rx_fp: The PRLI request frame - * - * Locking Note: The rport lock is expected to be held before calling - * this function. */ static void fc_rport_recv_rls_req(struct fc_rport_priv *rdata, struct fc_frame *rx_fp) @@ -1634,6 +1625,8 @@ static void fc_rport_recv_rls_req(struct fc_rport_priv *rdata, struct fc_seq_els_data rjt_data; struct fc_host_statistics *hst; + lockdep_assert_held(&rdata->rp_mutex); + FC_RPORT_DBG(rdata, "Received RLS request while in state %s\n", fc_rport_state(rdata)); @@ -1687,8 +1680,6 @@ out: * Handle incoming ELS requests that require port login. * The ELS opcode has already been validated by the caller. * - * Locking Note: Called with the lport lock held. - * * Reference counting: does not modify kref */ static void fc_rport_recv_els_req(struct fc_lport *lport, struct fc_frame *fp) @@ -1696,6 +1687,8 @@ static void fc_rport_recv_els_req(struct fc_lport *lport, struct fc_frame *fp) struct fc_rport_priv *rdata; struct fc_seq_els_data els_data; + lockdep_assert_held(&lport->lp_mutex); + rdata = fc_rport_lookup(lport, fc_frame_sid(fp)); if (!rdata) { FC_RPORT_ID_DBG(lport, fc_frame_sid(fp), @@ -1783,14 +1776,14 @@ busy: * @lport: The local port that received the request * @fp: The request frame * - * Locking Note: Called with the lport lock held. - * * Reference counting: does not modify kref */ void fc_rport_recv_req(struct fc_lport *lport, struct fc_frame *fp) { struct fc_seq_els_data els_data; + lockdep_assert_held(&lport->lp_mutex); + /* * Handle FLOGI, PLOGI and LOGO requests separately, since they * don't require prior login. @@ -1831,8 +1824,6 @@ EXPORT_SYMBOL(fc_rport_recv_req); * @lport: The local port that received the PLOGI request * @rx_fp: The PLOGI request frame * - * Locking Note: The rport lock is held before calling this function. - * * Reference counting: increments kref on return */ static void fc_rport_recv_plogi_req(struct fc_lport *lport, @@ -1845,6 +1836,8 @@ static void fc_rport_recv_plogi_req(struct fc_lport *lport, struct fc_seq_els_data rjt_data; u32 sid; + lockdep_assert_held(&lport->lp_mutex); + sid = fc_frame_sid(fp); FC_RPORT_ID_DBG(lport, sid, "Received PLOGI request\n"); @@ -1955,9 +1948,6 @@ reject: * fc_rport_recv_prli_req() - Handler for process login (PRLI) requests * @rdata: The remote port that sent the PRLI request * @rx_fp: The PRLI request frame - * - * Locking Note: The rport lock is expected to be held before calling - * this function. */ static void fc_rport_recv_prli_req(struct fc_rport_priv *rdata, struct fc_frame *rx_fp) @@ -1976,6 +1966,8 @@ static void fc_rport_recv_prli_req(struct fc_rport_priv *rdata, struct fc_seq_els_data rjt_data; struct fc4_prov *prov; + lockdep_assert_held(&rdata->rp_mutex); + FC_RPORT_DBG(rdata, "Received PRLI request while in state %s\n", fc_rport_state(rdata)); @@ -2072,9 +2064,6 @@ drop: * fc_rport_recv_prlo_req() - Handler for process logout (PRLO) requests * @rdata: The remote port that sent the PRLO request * @rx_fp: The PRLO request frame - * - * Locking Note: The rport lock is expected to be held before calling - * this function. */ static void fc_rport_recv_prlo_req(struct fc_rport_priv *rdata, struct fc_frame *rx_fp) @@ -2091,6 +2080,8 @@ static void fc_rport_recv_prlo_req(struct fc_rport_priv *rdata, unsigned int plen; struct fc_seq_els_data rjt_data; + lockdep_assert_held(&rdata->rp_mutex); + FC_RPORT_DBG(rdata, "Received PRLO request while in state %s\n", fc_rport_state(rdata)); @@ -2144,9 +2135,6 @@ drop: * @lport: The local port that received the LOGO request * @fp: The LOGO request frame * - * Locking Note: The rport lock is expected to be held before calling - * this function. - * * Reference counting: drops kref on return */ static void fc_rport_recv_logo_req(struct fc_lport *lport, struct fc_frame *fp) @@ -2154,6 +2142,8 @@ static void fc_rport_recv_logo_req(struct fc_lport *lport, struct fc_frame *fp) struct fc_rport_priv *rdata; u32 sid; + lockdep_assert_held(&lport->lp_mutex); + fc_seq_els_rsp_send(fp, ELS_LS_ACC, NULL); sid = fc_frame_sid(fp); |