From patchwork Fri May 5 09:09:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1777481 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=I+wlnrn2; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QCPz22BJnz214J for ; Fri, 5 May 2023 19:10:04 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1purRn-0002Ef-CL; Fri, 05 May 2023 09:09:51 +0000 Received: from mail-pl1-f169.google.com ([209.85.214.169]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1purRk-0002E9-By for kernel-team@lists.ubuntu.com; Fri, 05 May 2023 09:09:48 +0000 Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1aaea43def7so10139555ad.2 for ; Fri, 05 May 2023 02:09:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683277786; x=1685869786; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=FquCOw+yiiLnu9LkrXfrPUaXyfTWZgA06yrk3hflS1g=; b=I+wlnrn2uoE9zqzfxVTttQ0QRe0T8kBhHOd2RKzCDcOw543wUQkg4wEk2D3LRHEARy LD+q72fpAQnALcw9Bgxl16erXjAtyoSY/UDkJIgih5r4NUmsKSXpr9cg4AVYFH99GvZa 41DEAuO0GebC8u/HdP0ito1dEUO5ee96OpA4Uk6T/Z/Fl8buOgQ7KnkXDgUUfqn7LPpe TMaW7nZ19/1av0aSzyUNPk40r9kxXbNzRVrVK70ZcbsMm7Lx0O1SIP5C92O+amRWV9sz dnjUtdGbBMfrdNerWOXnFig837N8TvHdYOf3o2KFpME8/wC1/oTntLK1b4xhNTAv3gsN 2djg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683277786; x=1685869786; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=FquCOw+yiiLnu9LkrXfrPUaXyfTWZgA06yrk3hflS1g=; b=hTxpLNd/vxMwRQCBnhby0ZAaNaeVG1QLPSpjnHeWRZr4bLMFArc2s7Uxh1U5Yug/Sr SuvcNiS+KNXCrZe2YurtOpU1BFWUeCCJwTex1aLod/X4iHTF1G5Jquz+UQ3ahyagOVF0 97S6uJ2CvB2KwjxEQESSThCjpOQOsNQfl1RicXvpi0zC82M4Bx9NOAEPPdweI8DQ3JGc LN81VWEiO60577nywv2rFnyce6t0RyEFS6zdWLpxsAWg14C/NMIdL53cSGnWyK5mafac uR5Vgme5yWVVXR60HH46JzxZbSKDhutRaitjofMcoCOITc962myuBEJK8lKz/On4m8RO dcFQ== X-Gm-Message-State: AC+VfDyNfNIH8ci2XQydeDxx4u+DHK5NCDiju7CWGFmzhLL21XaYQ8Db VAKhLbr/8f7AP2Tk+90KnHewVEyfnd/sLg== X-Google-Smtp-Source: ACHHUZ6yMKWgDVu9fLRHCbXPa3OYd5ueKTOqphFeUbYdiw9s/JRb3Y7ZyNFZwDMvFHHWVpSwIUZgcQ== X-Received: by 2002:a17:902:d4cb:b0:1a6:d763:3736 with SMTP id o11-20020a170902d4cb00b001a6d7633736mr811500plg.58.1683277786275; Fri, 05 May 2023 02:09:46 -0700 (PDT) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id c14-20020a170902d48e00b001a943c41c37sm1237273plg.7.2023.05.05.02.09.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 02:09:45 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/2][SRU][OEM-6.1][OEM-6.0] UBUNTU: SAUCE: PM: suspend: Define pm_suspend_target_state Date: Fri, 5 May 2023 17:09:40 +0800 Message-Id: <20230505090941.384230-2-acelan.kao@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230505090941.384230-1-acelan.kao@canonical.com> References: <20230505090941.384230-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.169; envelope-from=acelan@gmail.com; helo=mail-pl1-f169.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kai-Heng Feng BugLink: https://launchpad.net/bugs/2018566 Define pm_suspend_target_state so it can still be used when CONFIG_SUSPEND is not set. Signed-off-by: Kai-Heng Feng (cherry picked from commit https://patchwork.kernel.org/project/linux-pm/patch/20230502150435.423770-1-kai.heng.feng@canonical.com/) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/base/power/wakeup.c | 5 ----- include/linux/suspend.h | 4 +++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index 7cc0c0cf8eaa..a917219feea6 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -19,11 +19,6 @@ #include "power.h" -#ifndef CONFIG_SUSPEND -suspend_state_t pm_suspend_target_state; -#define pm_suspend_target_state (PM_SUSPEND_ON) -#endif - #define list_for_each_entry_rcu_locked(pos, head, member) \ list_for_each_entry_rcu(pos, head, member, \ srcu_read_lock_held(&wakeup_srcu)) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index cfe19a028918..8f7f16c91479 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -199,6 +199,7 @@ struct platform_s2idle_ops { }; #ifdef CONFIG_SUSPEND +extern suspend_state_t pm_suspend_target_state; extern suspend_state_t mem_sleep_current; extern suspend_state_t mem_sleep_default; @@ -334,6 +335,8 @@ extern bool sync_on_suspend_enabled; #else /* !CONFIG_SUSPEND */ #define suspend_valid_only_mem NULL +#define pm_suspend_target_state (PM_SUSPEND_ON) + static inline void pm_suspend_clear_flags(void) {} static inline void pm_set_suspend_via_firmware(void) {} static inline void pm_set_resume_via_firmware(void) {} @@ -498,7 +501,6 @@ extern void ksys_sync_helper(void); /* drivers/base/power/wakeup.c */ extern bool events_check_enabled; -extern suspend_state_t pm_suspend_target_state; extern bool pm_wakeup_pending(void); extern void pm_system_wakeup(void); From patchwork Fri May 5 09:09:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1777483 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=ZsFknhOD; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QCPz22JS2z214K for ; Fri, 5 May 2023 19:10:04 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1purRq-0002FM-J5; Fri, 05 May 2023 09:09:54 +0000 Received: from mail-pl1-f172.google.com ([209.85.214.172]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1purRn-0002ER-1q for kernel-team@lists.ubuntu.com; Fri, 05 May 2023 09:09:51 +0000 Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1aaf21bb42bso10283095ad.2 for ; Fri, 05 May 2023 02:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683277789; x=1685869789; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=D8seDsT7PO2CPrKZfo3bCArjLGr5T+I5Ur2cXNmUdZw=; b=ZsFknhODCA/ghVV9EgBEcCT97SoO4hzU99Q2WYRRbMxwp25G2m+68W1A4eO4fl9Cam XZcZ7Csgk3FFhrqnS/bDSexANG8WyM3yplc6vlKiyaxLxUEPlaEdOyhDOZB2OMVjX0Ql cHgO/Eumu2tr8S1MkNoOSTFNFMCPO1vB8rHB3pvkDKMCsP63EQJtiuG3QNeqp8CLPE0Q Rb4KcUyfJbZjlmbx+CyK/sed/96ZTArcGviL+GFljGsc10kkbH2ZQb3xaz1fyVNIT5n2 3hLSngaNOPW8ZBnVK505PjOC5nxup6AwRTIJGbdgvlaLHQ+Ifke1F5tdmpQd/9Xjvn/f 3+TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683277789; x=1685869789; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=D8seDsT7PO2CPrKZfo3bCArjLGr5T+I5Ur2cXNmUdZw=; b=ChjVyMz6Dug90Xovu37QB5cCB+nciLD3vtfaN5k1chbQL5/n8jVwqKDDXiJgV56EwU ew82y/wXWGKtlFTe3X1VnQ/OpD5XLChzisQ8GjotFC8PIrFtdAVbCI2Cf9gdZMaJSanM TK3LVezv0Zz+jgub13pDdWnhC5Ace3XqlXq7zRew5mHGrA/b8nqyUuZkf7hVeEmuLAxX bGVNwIpZliqjjLixqAq1IPVL9LTA+LoQO4pEHu10N8rkWVq/PKSD75mjcs+ubb1rr6cC mNvsZBiTaMkv1OHAWlAFp4smm0lJnZLy06U+rWiMGuoxL+E9ynY0Kf29n1diq34BWNHG ttXw== X-Gm-Message-State: AC+VfDxGMXzy5TtnKURqsuopLC1gYRdpGbNZIgDfLZyL4mvixzVFRb84 4jWfC4VGFZzAib7pwYzNUedzjk9mE0mQOA== X-Google-Smtp-Source: ACHHUZ7+8c1ZG2Vbve/9OZc/2di109rdWt4SSsyR573FrLC+wr8h0tAhO5eKXh0PP/esGaT14KdDXQ== X-Received: by 2002:a17:903:48e:b0:1a2:a904:c438 with SMTP id jj14-20020a170903048e00b001a2a904c438mr741733plb.58.1683277788563; Fri, 05 May 2023 02:09:48 -0700 (PDT) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id u10-20020a170902e80a00b001ab1cdb4295sm1185530plg.130.2023.05.05.02.09.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 02:09:48 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/2][SRU][OEM-6.1][EOM-6.0] UBUNTU: SAUCE: ata: libata: Defer rescan on suspended device Date: Fri, 5 May 2023 17:09:41 +0800 Message-Id: <20230505090941.384230-3-acelan.kao@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230505090941.384230-1-acelan.kao@canonical.com> References: <20230505090941.384230-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.172; envelope-from=acelan@gmail.com; helo=mail-pl1-f172.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kai-Heng Feng BugLink: https://launchpad.net/bugs/2018566 During system resume, if an EH is schduled after ATA host is resumed (i.e. ATA_PFLAG_PM_PENDING cleared), but before the disk device is fully resumed, the device_lock hold by scsi_rescan_device() is never released so the dpm_resume() of the disk is blocked forerver. That's because scsi_attach_vpd() is expecting the disk device is in operational state, as it doesn't work on suspended device. To avoid such deadlock, defer rescan if the disk is still suspended so the resume process of the disk device can proceed. At the end of the resume process, use the complete() callback to schedule the rescan task. Signed-off-by: Kai-Heng Feng (cherry picked from commit https://patchwork.ozlabs.org/project/linux-ide/patch/20230502150435.423770-2-kai.heng.feng@canonical.com/) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/ata/libata-core.c | 11 +++++++++++ drivers/ata/libata-eh.c | 11 +++++++++-- include/linux/libata.h | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index a5ea144722fa..fec17fd1f49f 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -5058,6 +5058,16 @@ static int ata_port_pm_poweroff(struct device *dev) return 0; } +static void ata_port_pm_complete(struct device *dev) +{ + struct ata_port *ap = to_ata_port(dev); + + if (ap->pflags & ATA_PFLAG_DEFER_RESCAN) + schedule_work(&(ap->scsi_rescan_task)); + + ap->pflags &= ~ATA_PFLAG_DEFER_RESCAN; +} + static const unsigned int ata_port_resume_ehi = ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; @@ -5123,6 +5133,7 @@ static const struct dev_pm_ops ata_port_pm_ops = { .thaw = ata_port_pm_resume, .poweroff = ata_port_pm_poweroff, .restore = ata_port_pm_resume, + .complete = ata_port_pm_complete, .runtime_suspend = ata_port_runtime_suspend, .runtime_resume = ata_port_runtime_resume, diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 08e11bc312c2..83aeeed03196 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -2972,8 +2973,14 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link, */ ehc->i.flags |= ATA_EHI_SETMODE; - /* schedule the scsi_rescan_device() here */ - schedule_work(&(ap->scsi_rescan_task)); + /* Schedule the scsi_rescan_device() here. + * Defer the rescan if it's in process of + * suspending or resuming. + */ + if (pm_suspend_target_state != PM_SUSPEND_ON) + ap->pflags |= ATA_PFLAG_DEFER_RESCAN; + else + schedule_work(&(ap->scsi_rescan_task)); } else if (dev->class == ATA_DEV_UNKNOWN && ehc->tries[dev->devno] && ata_class_enabled(ehc->classes[dev->devno])) { diff --git a/include/linux/libata.h b/include/linux/libata.h index fe990176e6ee..a1f2e1a9b546 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -189,6 +189,7 @@ enum { ATA_PFLAG_UNLOADING = (1 << 9), /* driver is being unloaded */ ATA_PFLAG_UNLOADED = (1 << 10), /* driver is unloaded */ + ATA_PFLAG_DEFER_RESCAN = (1 << 16), /* peform deferred rescan on system resume */ ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */ ATA_PFLAG_INIT_GTM_VALID = (1 << 19), /* initial gtm data valid */