From patchwork Sun Jun 23 17:38:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 11011889 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 59E5614E5 for ; Sun, 23 Jun 2019 17:38:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 406EB28A6F for ; Sun, 23 Jun 2019 17:38:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 344FA28AB9; Sun, 23 Jun 2019 17:38:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFB7928A9D for ; Sun, 23 Jun 2019 17:38:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbfFWRim (ORCPT ); Sun, 23 Jun 2019 13:38:42 -0400 Received: from mail-eopbgr820058.outbound.protection.outlook.com ([40.107.82.58]:46146 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726718AbfFWRim (ORCPT ); Sun, 23 Jun 2019 13:38:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=micron.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uKNdVwuWPQ6+Ma7r9s1BrMJRxa5BXYVhunKUxWS4WEs=; b=uWwzJJC5PHpWskVe/rw98MF4uilVciSHy/tpleLJARBnKpdi2dZpkqZkwTWdpH4IkRqmSOk0BTnM+FVY30wUrQoVg13w3Mg/5LL5xGghFEVdIBReHEXQjxvqlRtQrskS+v2h5UwZlHyh116MIB6EeTspnWrFD1Iyvm5EwuqGUtM= Received: from BN7PR08MB5684.namprd08.prod.outlook.com (20.176.31.141) by BN7PR08MB4241.namprd08.prod.outlook.com (52.133.222.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.13; Sun, 23 Jun 2019 17:38:39 +0000 Received: from BN7PR08MB5684.namprd08.prod.outlook.com ([fe80::4dd2:da15:6626:c3b0]) by BN7PR08MB5684.namprd08.prod.outlook.com ([fe80::4dd2:da15:6626:c3b0%3]) with mapi id 15.20.2008.014; Sun, 23 Jun 2019 17:38:39 +0000 From: "Bean Huo (beanhuo)" To: Alim Akhtar , Avri Altman , Pedro Sousa , "Martin K. Petersen" CC: "James E.J. Bottomley" , Evan Green , Stanley Chu , "linux-kernel@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "Bean Huo (beanhuo)" Subject: [PATCH v2 2/3] scsi: ufs-bsg: fix typo in ufs_bsg_request Thread-Topic: [PATCH v2 2/3] scsi: ufs-bsg: fix typo in ufs_bsg_request Thread-Index: AdUp6T3Xt41XLu9MQdqAaZ+DpHy+6Q== Date: Sun, 23 Jun 2019 17:38:39 +0000 Message-ID: Accept-Language: en-150, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=beanhuo@micron.com; x-originating-ip: [165.225.81.56] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ac89d705-d23d-4912-982a-08d6f801a083 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:BN7PR08MB4241; x-ms-traffictypediagnostic: BN7PR08MB4241:|BN7PR08MB4241: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4941; x-forefront-prvs: 00770C4423 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39860400002)(376002)(136003)(396003)(366004)(189003)(199004)(2906002)(52536014)(110136005)(71190400001)(26005)(102836004)(6506007)(74316002)(55236004)(14444005)(186003)(256004)(476003)(4326008)(4744005)(73956011)(316002)(71200400001)(486006)(81156014)(14454004)(66066001)(66946007)(81166006)(305945005)(7736002)(66476007)(5660300002)(8676002)(66446008)(66556008)(64756008)(54906003)(9686003)(478600001)(76116006)(86362001)(6436002)(68736007)(7696005)(53936002)(55016002)(33656002)(25786009)(8936002)(3846002)(6116002)(107886003)(99286004);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR08MB4241;H:BN7PR08MB5684.namprd08.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: micron.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Yq/vxWlHQv0Yu4q99EhvczRmkm3rWqoMTU6+uAXexUCK+zkGehHaeWttc2Y1gKzrH4nHSmH2rk3r99E2Sl6GfH/8sb8lYHANqWxKTg8wPJW2XQYi8UH3gsDVTLbYKz6A8vRDixtLyQA6maOAi6KdG2wNEtSj/x6yBg+g1qCcrLt8YpIAtBHi6q+g3bfzQxl2VAqpBbvSryqczEKalckJH4x+FqphLKKsolIOYa35UYBwdsOXagZhCrNS2pd9GKxydKh0Jy0jJLElkLI34Duqb5uFlkfog8RKEtwoBugCKG/a3Qmp9e0DAHgrVQTZfSH0UTR7nsygZGpKTTW9BvhKoYkbrYVzkCc1dNeKSYMuIP7bbEKq1QNyQKCUYyOBnk7hsTv8Ph87/9moUG8RBaw+yYgxppbm9sIQMhJotaIIzos= MIME-Version: 1.0 X-OriginatorOrg: micron.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac89d705-d23d-4912-982a-08d6f801a083 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jun 2019 17:38:39.0168 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f38a5ecd-2813-4862-b11b-ac1d563c806f X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: beanhuo@micron.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR08MB4241 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bean Huo Correct dev_dbg to dev_err, so as to print out the error information in case of DME command failed. Signed-off-by: Bean Huo --- drivers/scsi/ufs/ufs_bsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c index 869e71f861d6..f420d6f8d84c 100644 --- a/drivers/scsi/ufs/ufs_bsg.c +++ b/drivers/scsi/ufs/ufs_bsg.c @@ -122,7 +122,7 @@ static int ufs_bsg_request(struct bsg_job *job) memcpy(&uc, &bsg_request->upiu_req.uc, UIC_CMD_SIZE); ret = ufshcd_send_uic_cmd(hba, &uc); if (ret) - dev_dbg(hba->dev, + dev_err(hba->dev, "send uic cmd: error code %d\n", ret); memcpy(&bsg_reply->upiu_rsp.uc, &uc, UIC_CMD_SIZE); From patchwork Sun Jun 23 17:38:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 11011891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B25AF14E5 for ; Sun, 23 Jun 2019 17:39:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96DFB28A6F for ; Sun, 23 Jun 2019 17:39:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8ACDD28AB9; Sun, 23 Jun 2019 17:39:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29D9328A6F for ; Sun, 23 Jun 2019 17:39:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726809AbfFWRi7 (ORCPT ); Sun, 23 Jun 2019 13:38:59 -0400 Received: from mail-eopbgr750042.outbound.protection.outlook.com ([40.107.75.42]:34286 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726718AbfFWRi7 (ORCPT ); Sun, 23 Jun 2019 13:38:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=micron.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=28wRNNOko65sM5APfnB/ZqIQlZWhViFUGA91pMekh0U=; b=ALVYl2lg323fRnCj/13t1lOjy+JoujO5cPU8IeQi5tTIrOX782RmgLjRaPpmqjjLQJFaSfCpm8zPN6+nSJCvqwf7uaxc9NAb48eZju74uEiLCuNrg/iq0hY1uiqwm1f+PG7ZcR/nnmRgw1q9Zpki/0tnDCjP0ZnAVgySnRbTrfo= Received: from BN7PR08MB5684.namprd08.prod.outlook.com (20.176.31.141) by BN7PR08MB4241.namprd08.prod.outlook.com (52.133.222.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.13; Sun, 23 Jun 2019 17:38:57 +0000 Received: from BN7PR08MB5684.namprd08.prod.outlook.com ([fe80::4dd2:da15:6626:c3b0]) by BN7PR08MB5684.namprd08.prod.outlook.com ([fe80::4dd2:da15:6626:c3b0%3]) with mapi id 15.20.2008.014; Sun, 23 Jun 2019 17:38:57 +0000 From: "Bean Huo (beanhuo)" To: Alim Akhtar , Avri Altman , Pedro Sousa , "Martin K. Petersen" CC: "James E.J. Bottomley" , Evan Green , Stanley Chu , "linux-kernel@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "Bean Huo (beanhuo)" Subject: [PATCH v2 3/3] scsi: ufs-bsg: complete ufs-bsg job only if no error Thread-Topic: [PATCH v2 3/3] scsi: ufs-bsg: complete ufs-bsg job only if no error Thread-Index: AdUp6Srmpfy7wc9rSjiZVcf65uZncg== Date: Sun, 23 Jun 2019 17:38:56 +0000 Message-ID: Accept-Language: en-150, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=beanhuo@micron.com; x-originating-ip: [165.225.81.56] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: bfcbba79-46fd-4fd0-f8f6-08d6f801ab36 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:BN7PR08MB4241; x-ms-traffictypediagnostic: BN7PR08MB4241:|BN7PR08MB4241: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 00770C4423 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39860400002)(376002)(136003)(396003)(366004)(189003)(199004)(2906002)(52536014)(110136005)(71190400001)(26005)(102836004)(6506007)(74316002)(55236004)(14444005)(186003)(256004)(476003)(4326008)(73956011)(316002)(71200400001)(486006)(81156014)(14454004)(66066001)(66946007)(81166006)(305945005)(7736002)(66476007)(5660300002)(8676002)(66446008)(66556008)(64756008)(54906003)(9686003)(478600001)(76116006)(86362001)(6436002)(68736007)(7696005)(53936002)(55016002)(33656002)(25786009)(8936002)(3846002)(6116002)(107886003)(99286004);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR08MB4241;H:BN7PR08MB5684.namprd08.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: micron.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: +Vaazy45kVuDhFvVO0byDaeaQEGl0tCpzTSDLqYEQHRyuPi7/fnMtwvJH/tavaiQMa0QpI5ypmnKyia13CfFBKo/3O5+onCWufW/FQMJLJyEIepmX8WTWwRjVTzx05o74oJEZdswUyZi05sv3dWr8qtol5tx0AWUAk2m4Qod65FDSHLUWrhLYm2eBu9A7eLSDyPw02VHwyCcEvM5zwtDBdbCdVlxddbkY4qY7K9gIxvIoxOQhHOPmK9hB6ZGJ5cuQIdLoGgDYJwmlAD4Javn348Z99Xdefz/xzmDtf/h41067+Iv8/eWZxUtW6BVFLRBduPXvwp72jjXycbW6I3+oHJhAWDN9fDNIldxOjVhupMCFl80UeGfuNFL1uiqSONkahnWMzpMhzjGMmRwYSY/ytowWmeC+iQxjyIC+sMo2vQ= MIME-Version: 1.0 X-OriginatorOrg: micron.com X-MS-Exchange-CrossTenant-Network-Message-Id: bfcbba79-46fd-4fd0-f8f6-08d6f801ab36 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jun 2019 17:38:56.9107 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f38a5ecd-2813-4862-b11b-ac1d563c806f X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: beanhuo@micron.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR08MB4241 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bean Huo In the case of UPIU/DME request execution failed in UFS device, ufs_bsg_request() will complete this failed bsg job by calling bsg_job_done(). Meanwhile, it returns this error status to blk-mq layer, then triggers blk-mq completing this request again, this will cause below panic. Call trace: ll_sc___cmpxchg_case_acq_32+0x4/0x20 complete+0x28/0x70 blk_end_sync_rq+0x24/0x30 blk_mq_end_request+0xb8/0x118 bsg_job_put+0x4c/0x58 bsg_complete+0x20/0x30 blk_done_softirq+0xb4/0xe8 do_softirq+0x154/0x3f0 run_ksoftirqd+0x4c/0x68 smpboot_thread_fn+0x22c/0x268 kthread+0x130/0x138 ret_from_fork+0x10/0x1c Code: f84107fe d65f03c0 d503201f f9800011 (885ffc10) ---[ end trace d92825bff6326e66 ]--- Kernel panic - not syncing: Fatal exception in interrupt This patch is to fix this issue. The solution is we complete the ufs-bsg job only if no error happened. Fixes: df032bf27a41 (scsi: ufs: Add a bsg endpoint that supports UPIUs) Signed-off-by: Bean Huo --- drivers/scsi/ufs/ufs_bsg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c index f420d6f8d84c..a9344eb4e047 100644 --- a/drivers/scsi/ufs/ufs_bsg.c +++ b/drivers/scsi/ufs/ufs_bsg.c @@ -149,7 +149,9 @@ static int ufs_bsg_request(struct bsg_job *job) out: bsg_reply->result = ret; job->reply_len = sizeof(struct ufs_bsg_reply); - bsg_job_done(job, ret, bsg_reply->reply_payload_rcv_len); + /* complete the job here only if no error */ + if (ret == 0) + bsg_job_done(job, ret, bsg_reply->reply_payload_rcv_len); return ret; }