Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752564AbdF1Qdi (ORCPT ); Wed, 28 Jun 2017 12:33:38 -0400 Received: from mail-bl2nam02on0067.outbound.protection.outlook.com ([104.47.38.67]:55962 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752536AbdF1QdS (ORCPT ); Wed, 28 Jun 2017 12:33:18 -0400 From: "Madhani, Himanshu" To: Johannes Thumshirn CC: "Martin K . Petersen" , Linux SCSI Mailinglist , Linux Kernel Mailinglist , Dept-Eng QLA2xxx Upstream , Hannes Reinecke , John Garry Subject: Re: [PATCH v2] qla2xxx: Protect access to qpair members with qpair->qp_lock Thread-Topic: [PATCH v2] qla2xxx: Protect access to qpair members with qpair->qp_lock Thread-Index: AQHS6+/hvui4g7XsLECAwrSpzEYl+KI6gJmA Date: Wed, 28 Jun 2017 16:33:16 +0000 Message-ID: <7686A840-575D-4760-8D83-372394F59041@cavium.com> References: <20170623071011.21184-1-jthumshirn@suse.de> In-Reply-To: <20170623071011.21184-1-jthumshirn@suse.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: suse.de; dkim=none (message not signed) header.d=none;suse.de; dmarc=none action=none header.from=cavium.com; x-originating-ip: [173.186.134.106] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR07MB3453;7:yWAh+TgDh4+N1CrsPkf5U24Q1qSBJWdUAzjBKxtbr87ZeeOf3pYrgEUF6dkicyNbc/S2huBImZyJ+A3bt9iK01sElFT8Gc3kmg/+BcVBYPZeqv4vZWnMg6Rx3xqMY017UBhy6e+h+9tY0P1xuvRZd+2KzZG8C8nliYG7iPV6c2SQ1Eb0MBZ5P7p4GP4PuRmm6/pNlHM56X3LJ8Bwslba0dnum4oIWtIaRZF7OwD2MZ2u0UbMHIVzTM4AYFBehN4t28lBnr+I6lMEjAQsrCY2x4ge5tycKFAjhjwZuEA+sI9PnIUR5i3IUogiN4GNfsMtr+sm0oVdFRWayS8Eo9G4BhCtHlX5UCr0Qgl+9tK2I2a91+CfYTOrMjRrOF1xDiyPT6U8NsDjxym9f2dEVIphXu9A5EgmnndQMdeXjW8TV84Pmz8EAo/eB70KIOBB5eJuEIcZ5lttzgQ3ojMmEfrJ37kfg/jttSq5DvgB1SPlcL7yYkxUkjmosqw5vZwc5GE5aPCCpGfopD2GiEc4vCDgqa/VEc5wTNRqg7qaDolFHHBlSftwbo83EYzas+zYuOdCkXIWkFDEvoWH4mc9RElHRCLgKxr8kkUOcDep4VPLY5LAPhYCh6S6O7KUbageNgm+bdjh+m+2Cay2KxsXgdM+ywa23FqEBqJAKuj2X84mx+BBOqWkv8jbULp6hgZMCXDcFX4lS2l6Ny4fXB0AitjCeZcKd2qptLLzcqTAyYl6Lu3eCUikcZHU2sIDEPsAXQ0YBLsM5B5y0uAEY8RWIH3UhDKKgFbPIUFEES+UKJR2gBw= x-ms-office365-filtering-correlation-id: bddfb3f3-c36d-46aa-85c1-08d4be4360cb x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:MWHPR07MB3453; x-ms-traffictypediagnostic: MWHPR07MB3453: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(209352067349851)(236129657087228); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6041248)(20161123558100)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR07MB3453;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR07MB3453; x-forefront-prvs: 03524FBD26 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39450400003)(39850400002)(39400400002)(39410400002)(377454003)(24454002)(54906002)(2900100001)(6512007)(5660300001)(99286003)(38730400002)(8936002)(6486002)(77096006)(6246003)(229853002)(36756003)(8676002)(110136004)(478600001)(33656002)(72206003)(81166006)(189998001)(6116002)(7736002)(3846002)(14454004)(53936002)(76176999)(50986999)(54356999)(102836003)(6436002)(6506006)(86362001)(53546010)(82746002)(6916009)(25786009)(83716003)(2906002)(4326008)(3280700002)(2950100002)(3660700001)(305945005)(66066001);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR07MB3453;H:MWHPR07MB3455.namprd07.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <499A949F5D27CD49B9CF1CA9822BD42A@namprd07.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jun 2017 16:33:16.1025 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3453 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v5SGXk64015541 Content-Length: 2930 Lines: 91 > On Jun 23, 2017, at 12:10 AM, Johannes Thumshirn wrote: > > In qla2xx_start_scsi_mq() and qla2xx_dif_start_scsi_mq() we grab the > qpair->qp_lock but do access members of the qpair before having the lock. > Re-order the locking sequence to have all read and write access to qpair > members under the qpair->qp_lock. > > Signed-off-by: Johannes Thumshirn > --- > drivers/scsi/qla2xxx/qla_iocb.c | 23 +++++++++++++---------- > 1 file changed, 13 insertions(+), 10 deletions(-) > > Changes to v1: > * Use __qla2x00_marker() instead of qla2x00_marker which is fit to be called > with the qp_lock held (John) > * Don't protect qpair->online and qpair->difdix_supported as it's not > needed (Hannes) > > diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c > index 8404f17f3c6c..c64036ddd365 100644 > --- a/drivers/scsi/qla2xxx/qla_iocb.c > +++ b/drivers/scsi/qla2xxx/qla_iocb.c > @@ -1770,6 +1770,9 @@ qla2xxx_start_scsi_mq(srb_t *sp) > struct qla_hw_data *ha = vha->hw; > struct qla_qpair *qpair = sp->qpair; > > + /* Acquire qpair specific lock */ > + spin_lock_irqsave(&qpair->qp_lock, flags); > + > /* Setup qpair pointers */ > rsp = qpair->rsp; > req = qpair->req; > @@ -1779,15 +1782,14 @@ qla2xxx_start_scsi_mq(srb_t *sp) > > /* Send marker if required */ > if (vha->marker_needed != 0) { > - if (qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) != > - QLA_SUCCESS) > + if (__qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) != > + QLA_SUCCESS) { > + spin_unlock_irqrestore(&qpair->qp_lock, flags); > return QLA_FUNCTION_FAILED; > + } > vha->marker_needed = 0; > } > > - /* Acquire qpair specific lock */ > - spin_lock_irqsave(&qpair->qp_lock, flags); > - > /* Check for room in outstanding command list. */ > handle = req->current_outstanding_cmd; > for (index = 1; index < req->num_outstanding_cmds; index++) { > @@ -1942,6 +1944,8 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp) > return qla2xxx_start_scsi_mq(sp); > } > > + spin_lock_irqsave(&qpair->qp_lock, flags); > + > /* Setup qpair pointers */ > rsp = qpair->rsp; > req = qpair->req; > @@ -1951,15 +1955,14 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp) > > /* Send marker if required */ > if (vha->marker_needed != 0) { > - if (qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) != > - QLA_SUCCESS) > + if (__qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) != > + QLA_SUCCESS) { > + spin_unlock_irqrestore(&qpair->qp_lock, flags); > return QLA_FUNCTION_FAILED; > + } > vha->marker_needed = 0; > } > > - /* Acquire ring specific lock */ > - spin_lock_irqsave(&qpair->qp_lock, flags); > - > /* Check for room in outstanding command list. */ > handle = req->current_outstanding_cmd; > for (index = 1; index < req->num_outstanding_cmds; index++) { > -- > 2.12.3 > Looks Good. Acked-By: Himanshu Madhani