Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1362431pxy; Sun, 1 Aug 2021 22:47:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbW1scpPpuKTybbhpuC+GI18dknHrjG7eM13kJjWnLXWOGT9J/bCC0KSjhHqQkkMOQY9Tj X-Received: by 2002:a05:6638:1646:: with SMTP id a6mr13252968jat.1.1627883271279; Sun, 01 Aug 2021 22:47:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627883271; cv=none; d=google.com; s=arc-20160816; b=XcRH2KqDEUTGQGemprZUqWgv3OCL15EwSGSmktyc8+GXJu7LYXJYEh/rpuoOYBCJ93 /SDrBoxosmbpRl1wuAbxEvb7J0MZFM3arO56REdHXgVYpOCTP3Pr9WGqFlhSsg8Z8B0l 0jsySbp9tu/yTjALQLl44ZePDf6KrTsJBBOU2MZypRDzgNEsM8RtfHUDyuHnTIyB6VRQ po4N/RiO+j+YFfCP1agpV3zIEorIEYzhb34Zo+F3JS53jDGGY1nwQdt4iNXXb5ObDgTq 8+m7Pz25+psJKDajUsNQi1rMI0PD2tt7ybrHxJeRhZoSmR4NFsSQS5eYshjyBMzfChX4 RW/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject; bh=EG+9dFP/erYdQ9NM2EnYCBNneAaeFg7QTT5SyR4pe6U=; b=Tr6+PgFSJgthoEnkpkUUI98EetDBICy2HYAxQBGWegkX30OzqT1yeE+Hj2DCeqfIE6 TbRrwoCdqcDD1rWbfHIhFfp/RAmOSMIiiNWyqSCmDgZxDgy+q90xRsAjlfaeBYPk24FS 0fqRPcHxvg+Tr6vzzf1LUGl5AD04f0JwIrYzI2PalRaga4d/+8j9KF8V8Csa2bJS5jrU RvPU8PhvhE4Ww3qFAgNH+W8Ou6F2KEBMtmTGgoDcFdF4JCrPtpxGv9mwtGHpGPbR+vmX qJ3/GnERPWzGiVM/kd6B5UyBAZpGnnTAD1ArtMGQ1PTxDFGG4rd8D0M9AHz6NyPkwAkB WQow== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q6si9103332jaj.77.2021.08.01.22.47.38; Sun, 01 Aug 2021 22:47:51 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbhHBFp2 (ORCPT + 99 others); Mon, 2 Aug 2021 01:45:28 -0400 Received: from mga11.intel.com ([192.55.52.93]:50717 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230417AbhHBFp1 (ORCPT ); Mon, 2 Aug 2021 01:45:27 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10063"; a="210282397" X-IronPort-AV: E=Sophos;i="5.84,288,1620716400"; d="scan'208";a="210282397" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Aug 2021 22:45:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,288,1620716400"; d="scan'208";a="509840578" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.79]) ([10.237.72.79]) by FMSMGA003.fm.intel.com with ESMTP; 01 Aug 2021 22:44:59 -0700 Subject: Re: [PATCH V4 2/2] scsi: ufshcd: Fix device links when BOOT WLUN fails to probe To: Avri Altman , "Rafael J . Wysocki" Cc: Greg Kroah-Hartman , Saravana Kannan , "Martin K . Petersen" , "James E . J . Bottomley" , "linux-scsi@vger.kernel.org" , Bean Huo , Can Guo , Asutosh Das , Bart Van Assche , "linux-pm@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20210716114408.17320-1-adrian.hunter@intel.com> <20210716114408.17320-3-adrian.hunter@intel.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <2a19830e-47cb-4c2a-ddbc-f2370af01452@intel.com> Date: Mon, 2 Aug 2021 08:45:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/07/21 9:02 pm, Avri Altman wrote: >> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c >> index 708b3b62fc4d..9864a8ee0263 100644 >> --- a/drivers/scsi/ufs/ufshcd.c >> +++ b/drivers/scsi/ufs/ufshcd.c >> @@ -5020,15 +5020,34 @@ static int ufshcd_slave_configure(struct scsi_device >> *sdev) >> static void ufshcd_slave_destroy(struct scsi_device *sdev) >> { >> struct ufs_hba *hba; >> + unsigned long flags; >> >> hba = shost_priv(sdev->host); >> /* Drop the reference as it won't be needed anymore */ >> if (ufshcd_scsi_to_upiu_lun(sdev->lun) == UFS_UPIU_UFS_DEVICE_WLUN) { >> - unsigned long flags; >> - >> spin_lock_irqsave(hba->host->host_lock, flags); >> hba->sdev_ufs_device = NULL; >> spin_unlock_irqrestore(hba->host->host_lock, flags); >> + } else if (hba->sdev_ufs_device) { >> + struct device *supplier = NULL; >> + >> + /* Ensure UFS Device WLUN exists and does not disappear */ >> + spin_lock_irqsave(hba->host->host_lock, flags); >> + if (hba->sdev_ufs_device) { > Was just checked in the outer clause? Yes, but need to re-check with the spinlock locked. > > Thanks, > Avri > >> + supplier = &hba->sdev_ufs_device->sdev_gendev; >> + get_device(supplier); >> + } >> + spin_unlock_irqrestore(hba->host->host_lock, flags); >> + >> + if (supplier) { >> + /* >> + * If a LUN fails to probe (e.g. absent BOOT WLUN), the >> + * device will not have been registered but can still >> + * have a device link holding a reference to the device. >> + */ >> + device_link_remove(&sdev->sdev_gendev, supplier); >> + put_device(supplier); >> + } >> } >> } >> >> -- >> 2.17.1 >