Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp496686pxb; Wed, 27 Jan 2021 13:02:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJymt9TiR79gS6N1vyv9MRHwQQBkx/6DLH1ILpgv/oXfAbGGjuqt/Hf8t55bhiSzHN0lX+Rq X-Received: by 2002:a17:906:ae91:: with SMTP id md17mr8270804ejb.302.1611781324688; Wed, 27 Jan 2021 13:02:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611781324; cv=none; d=google.com; s=arc-20160816; b=SfEodWZmkGWxCmGqXqy0XJaR35DVS0JYKM+/kx1EUvCr+uBjKFoIy1dVQiJY9OBj2l XeRvMnJYIeOO54RWOBLYbbeEVY3vZR0si2im9U4eiRouPwXnJ4YpTIkbu6eG+IgLIN4a t+OtkrUbMyIiuxfzhFUHVY6jxIvNf0Mw5/dFPczrk3aBuRJUT1LiAzhoSZYg/nFp52wf VG8MSWZ38Hvx8QGnDlWE2yI7aJU5Eb1oR7tZ1AADyAzo4qaj2iLmS5ruy3s4MhK+m1in WMlgeMRgSgD6a0qazcMmX3CAgwUauSBw7Lr0C6Hu5HoQhsnbUJPA1EJocTrigfvp2/0B uUUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr; bh=t/G2xT6m9A19AMD3EbC990VYom7nA1S2ZOyY+xdRv8o=; b=c6lw+i4HnOGkJXyTnCk4zGdu0oEsnI6Zrc9LdGFsZwmyiTRXd/isT+xQ5jaLInmtty bPS4d2QtKQgITd2ytYvr3F5xe3/YP2hPADApptLNaqyLqhNYKVw1HXURh54k7Ya/Z55/ ZqydW0w7oLy+SbQ2hGGuh9jJ8kRHvDfr7fbHOijV8m+CB36LP6ggGsAMci8OYxj0O9sG T3d0sRhSV3gEPi+C7JcWePmD5FKok8vk+Q8+Fs4w6OSCDwjhV6B2nND6+Bbs7v/CJNF5 tgudsHOwHdxITrx6UgsYjB/b6th7A3MaVjCHmyVyHaJ/D8ocCgtiAU8B2BQiOIV/B/y3 4LMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si1688684edw.598.2021.01.27.13.01.37; Wed, 27 Jan 2021 13:02:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238356AbhA0ENg (ORCPT + 99 others); Tue, 26 Jan 2021 23:13:36 -0500 Received: from labrats.qualcomm.com ([199.106.110.90]:46886 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238224AbhA0EJS (ORCPT ); Tue, 26 Jan 2021 23:09:18 -0500 X-Greylist: delayed 477 seconds by postgrey-1.27 at vger.kernel.org; Tue, 26 Jan 2021 23:09:10 EST IronPort-SDR: zMp0UeaATN8dAmwGUwJ/f7vfSKVLz9SPYEYrELP5OMt/VgAxzU5cksfjlratlBdfK0pJQ3z2rC x2a3ye/2oVbx5tzxjyyJZkznOGOcthLpltY27o/jPNQ6FF+zI8jL/bahGwA8PyJKtqfyXJ3Xj9 9R2xKP3PwznzerwKspmpMZ2O+N5CHBLIIdOny9+2atBXocI4fumPPj1NddbDvfw6vMw8uwIapO z0ZiW9vpyisAPT+sN2TJG3kuIFowA56cKA50d3K4EESWGnsgLVTMoErSwp5WQShPhJJs5oMAK6 C+o= X-IronPort-AV: E=Sophos;i="5.79,378,1602572400"; d="scan'208";a="47711299" Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by labrats.qualcomm.com with ESMTP; 26 Jan 2021 20:00:27 -0800 X-QCInternal: smtphost Received: from stor-presley.qualcomm.com ([192.168.140.85]) by ironmsg04-sd.qualcomm.com with ESMTP; 26 Jan 2021 20:00:26 -0800 Received: by stor-presley.qualcomm.com (Postfix, from userid 92687) id 6068421903; Tue, 26 Jan 2021 20:00:26 -0800 (PST) From: Asutosh Das To: cang@codeaurora.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org Cc: Asutosh Das , linux-arm-msm@vger.kernel.org, stern@rowland.harvard.edu, "Bao D . Nguyen" , FUJITA Tomonori , Jens Axboe , linux-block@vger.kernel.org (open list:BLOCK LAYER), linux-kernel@vger.kernel.org (open list) Subject: [RFC PATCH v1 1/2] block: bsg: resume scsi device before accessing Date: Tue, 26 Jan 2021 20:00:22 -0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Resumes the scsi device before accessing it. Change-Id: I2929af60f2a92c89704a582fcdb285d35b429fde Signed-off-by: Asutosh Das Signed-off-by: Can Guo Signed-off-by: Bao D. Nguyen --- block/bsg.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/block/bsg.c b/block/bsg.c index d7bae94..f4c197f 100644 --- a/block/bsg.c +++ b/block/bsg.c @@ -306,12 +306,16 @@ static struct bsg_device *bsg_get_device(struct inode *inode, struct file *file) static int bsg_open(struct inode *inode, struct file *file) { struct bsg_device *bd; + struct scsi_device *sd; bd = bsg_get_device(inode, file); if (IS_ERR(bd)) return PTR_ERR(bd); + sd = (struct scsi_device *) bd->queue->queuedata; + if (scsi_autopm_get_device(sd)) + return -EIO; file->private_data = bd; return 0; } @@ -319,8 +323,12 @@ static int bsg_open(struct inode *inode, struct file *file) static int bsg_release(struct inode *inode, struct file *file) { struct bsg_device *bd = file->private_data; + struct scsi_device *sd; file->private_data = NULL; + sd = (struct scsi_device *) bd->queue->queuedata; + scsi_autopm_put_device(sd); + return bsg_put_device(bd); } -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.