From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kashyap Desai Subject: RE: [PATCH v2 03/39] megaraid_sas: raid 1 fast path code optimize Date: Thu, 9 Feb 2017 00:21:33 +0530 Message-ID: <339b3daf3916e0ac6a1bb44f5040e172@mail.gmail.com> References: <1486546173-20713-1-git-send-email-shivasharan.srikanteshwara@broadcom.com> <1486546173-20713-4-git-send-email-shivasharan.srikanteshwara@broadcom.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from mail-qk0-f171.google.com ([209.85.220.171]:35184 "EHLO mail-qk0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751457AbdBHTTc (ORCPT ); Wed, 8 Feb 2017 14:19:32 -0500 Received: by mail-qk0-f171.google.com with SMTP id u25so132739783qki.2 for ; Wed, 08 Feb 2017 11:19:32 -0800 (PST) In-Reply-To: Sender: linux-scsi-owner@vger.kernel.org List-Id: linux-scsi@vger.kernel.org To: Tomas Henzl , Shivasharan Srikanteshwara , linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, Sumit Saxena , hare@suse.com > > +static inline void > > +megasas_complete_r1_command(struct megasas_instance *instance, > > + struct megasas_cmd_fusion *cmd) { > > + u8 *sense, status, ex_status; > > + u32 data_length; > > + u16 peer_smid; > > + struct fusion_context *fusion; > > + struct megasas_cmd_fusion *r1_cmd = NULL; > > + struct scsi_cmnd *scmd_local = NULL; > > + struct RAID_CONTEXT_G35 *rctx_g35; > > + > > + rctx_g35 = &cmd->io_request->RaidContext.raid_context_g35; > > + fusion = instance->ctrl_context; > > + peer_smid = le16_to_cpu(rctx_g35->smid.peer_smid); > > + > > + r1_cmd = fusion->cmd_list[peer_smid - 1]; > > + scmd_local = cmd->scmd; > > + status = rctx_g35->status; > > + ex_status = rctx_g35->ex_status; > > + data_length = cmd->io_request->DataLength; > > + sense = cmd->sense; > > + > > + cmd->cmd_completed = true; > > Please help me understand how this works > - there are two peer commands sent to the controller > - both are completed and the later calls scsi_done and returns both r1_cmd > + cmd > - if both commands can be completed at the same time, is it possible that > the > above line is executed at the same moment for both completions ? > How is the code protected against a double completion when both > completed commands see the peer cmd_completed as set ? Tomas, cmd and r1_cmd (part of same Raid 1 FP) will be always completed on same reply queue by firmware. That is one of the key requirement here for raid 1 fast path. What you ask is possible if FW completes cmd and r1_cmd on different reply queue. If you notice when we clone r1_cmd, we also clone MSI-x index from parent command. So eventually, FW is aware of binding of both cmd and r1_cmd w.r.t reply queue index. ` Kashyap > > > +