From patchwork Tue Sep 23 07:31:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dolev Raviv X-Patchwork-Id: 4953891 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 149099F2BB for ; Tue, 23 Sep 2014 07:32:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BFF3620158 for ; Tue, 23 Sep 2014 07:32:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7DEDB201D3 for ; Tue, 23 Sep 2014 07:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754762AbaIWHc0 (ORCPT ); Tue, 23 Sep 2014 03:32:26 -0400 Received: from smtp.codeaurora.org ([198.145.11.231]:40387 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754753AbaIWHcX (ORCPT ); Tue, 23 Sep 2014 03:32:23 -0400 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id A5E0D140349; Tue, 23 Sep 2014 07:32:22 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 9890B14034C; Tue, 23 Sep 2014 07:32:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lx-draviv2.mea.qualcomm.com (unknown [185.23.60.4]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: draviv@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5CFBC140349; Tue, 23 Sep 2014 07:32:20 +0000 (UTC) From: Dolev Raviv To: James.Bottomley@HansenPartnership.com, hch@infradead.org Cc: linux-scsi@vger.kernel.org, linux-scsi-owner@vger.kernel.org, linux-arm-msm@vger.kernel.org, santoshsy@gmail.com, Subhash Jadavani , Dolev Raviv Subject: [PATCH V4 09/17] scsi: ufs: manually add well known logical units Date: Tue, 23 Sep 2014 10:31:31 +0300 Message-Id: <1411457499-8074-10-git-send-email-draviv@codeaurora.org> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1411457499-8074-1-git-send-email-draviv@codeaurora.org> References: <1411457499-8074-1-git-send-email-draviv@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Subhash Jadavani According to SELECT REPORT field (of REPORT LUNS command) from SPC-4 (SCSI Primary Commands) specification, device should report all the LUNs (which support any of the addressing method specified in the description). Note that UFS W-LUs follow the extended logical unit addressing mothod hence according to SPC specification all the UFS W-LUs should be reported when SELECT REPORT field is to 00h. But it seems UFS specification has modified the meaning of SELECT REPORT field when its set to 00h. When SELECT REPORT field is cleared, device should only report LUs which support peripheral device addressing method. Even UFS Test specification seems to confirm this diversion from the spec. Hence it's reasonable for the UFS devices adhering to the UFS device specification to not report the W-LUs when SELECT REPORT is 00h. scsi_scan_host() would only scan LUs with SELECT REPORT set to 00h hence this patch manually add the UFS well known logical units. Signed-off-by: Subhash Jadavani Signed-off-by: Dolev Raviv diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index dc89c48..1c5422b 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -902,6 +902,17 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) } /** + * ufshcd_upiu_wlun_to_scsi_wlun - maps UPIU W-LUN id to SCSI W-LUN ID + * @scsi_lun: UPIU W-LUN id + * + * Returns SCSI W-LUN id + */ +static inline u16 ufshcd_upiu_wlun_to_scsi_wlun(u8 upiu_wlun_id) +{ + return (upiu_wlun_id & ~UFS_UPIU_WLUN_ID) | SCSI_W_LUN_BASE; +} + +/** * ufshcd_queuecommand - main entry point for SCSI requests * @cmd: command from SCSI Midlayer * @done: call back function @@ -3415,6 +3426,15 @@ static int ufshcd_probe_hba(struct ufs_hba *hba) if (!hba->is_init_prefetch) ufshcd_init_icc_levels(hba); + scsi_add_device(hba->host, 0, 0, + ufshcd_upiu_wlun_to_scsi_wlun( + UFS_UPIU_UFS_DEVICE_WLUN)); + scsi_add_device(hba->host, 0, 0, + ufshcd_upiu_wlun_to_scsi_wlun( + UFS_UPIU_BOOT_WLUN)); + scsi_add_device(hba->host, 0, 0, + ufshcd_upiu_wlun_to_scsi_wlun( + UFS_UPIU_RPMB_WLUN)); scsi_scan_host(hba->host); pm_runtime_put_sync(hba->dev); }