Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3040425pxb; Tue, 12 Jan 2021 05:03:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJx35JlVU8I7sM33r9YgS4e+dQsvmTKvfzMzusYHr2c+Z23IHWNa6B3NGD0f1BIrJEK/tVOK X-Received: by 2002:a17:906:4c4c:: with SMTP id d12mr3160212ejw.307.1610456593664; Tue, 12 Jan 2021 05:03:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610456593; cv=none; d=google.com; s=arc-20160816; b=wGaTgBJkIRTjX8JNPCGfr0V8ZzZUzw9otbMtrTzvXwyCNKJEG6JWC3W8cMA9iDbdB+ Rbf78sXszKU6HFkQerHqryoJvwe0eT4rR0aCFU3VhH8kfTQ2EvEQgF3RaW84IrldhzjG MNslvIFvxnzIZSF1kBcF2aBfJJzqqFKXqI93UE698ris/6Wlxjy0r02yNAWKsyZJYdii Es+NZTNHuEO3sL2O5bqxdSPcXHijIu7hhCwEGTq158rmT1+U8VlhzsawqBRdMmHhoWTr r/PAhnLClEfcUbuHd1LY5M09pws+wi8TAjeep2Ocpt1LwIpRBZEm861bhEVbdYB+KIz1 ysSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=Jyir26ynSGymnraXCeh2P93SjcPTZ0DbcdxeKKW9geM=; b=IP+DwAzD4gP6dQwqGV8mr44sdnypJdpgFvYZrYbmQBIHrMNAn901cU9mPlApg9Fa8N RR+aAq7ydWoLucFbK3xUtZbEafDYgyKa/9865kQ+s5k9AV2MFcnQByc02cGvYstfLPqC 6J4FFQCyresWWXd3J9vlF9WluNA0fOHCwd1Ry2WTvyZN5nYbPC0yBIPYeWt90AFqJ1EK ZubDqLveqcezKbawGsWyb9kzclbGuSHQqsg6aIo6uGzcvfuXoZ08WaNQOgTvdvArhkwL U4odxgmNsAsLcmV/8MO7+Cdr+dP94hK4eESRfVM31sETyF8fm+o8ax2+AMGNvKz2r/RB vqBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HaG2KiZi; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="I0v/LT2A"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e6si1435437edv.445.2021.01.12.05.02.49; Tue, 12 Jan 2021 05:03:13 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HaG2KiZi; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="I0v/LT2A"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730360AbhALLIA (ORCPT + 99 others); Tue, 12 Jan 2021 06:08:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730007AbhALLIA (ORCPT ); Tue, 12 Jan 2021 06:08:00 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2083C0617A2; Tue, 12 Jan 2021 03:07:19 -0800 (PST) From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1610449637; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jyir26ynSGymnraXCeh2P93SjcPTZ0DbcdxeKKW9geM=; b=HaG2KiZiE9OrZQTjdSER0pi/qJ5+nap8pgPAISPJ5qajcIcVIDTkro9l0TO8noo2p2aTUT Py5bB6c2MNE1DEtly+mV03D/kr4LRQXl7xpLcKL1emyjGG58cHvv6ymPPVDTFlnYY006h3 ih7+624IOc7wZUdXPfH2/WC8LhDLW4j3ZjBgtAND4ubnQjmYMPNye6QFrRrpx6IxGfm4uP dAC0Wq4h/KgAlv4jofFIBF+Tr+4LDE75x+IRj0p0kbqx6R8rJSK936SxZYaeXlmQCtdf0S Kv6/ndbvWtqkMKGhueQJWD6dKgY+3sRe5kjO+rqbASI7g2wVQ1NvKrokisLnEA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1610449637; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jyir26ynSGymnraXCeh2P93SjcPTZ0DbcdxeKKW9geM=; b=I0v/LT2AcVGl/Cw9xZQudk0gsYjS+QgORR66Vc7CxVBM2PLH+Tv4ba2ZZXk6ljzbsib5bf E4MYohM0aTvrOCCQ== To: "James E.J. Bottomley" , "Martin K. Petersen" , John Garry , Jason Yan , Daniel Wagner , Artur Paszkiewicz , Jack Wang Cc: linux-scsi@vger.kernel.org, intel-linux-scu@intel.com, LKML , Thomas Gleixner , "Sebastian A. Siewior" , "Ahmed S. Darwish" Subject: [PATCH v2 06/19] scsi: isci: port: link up: Pass gfp_t flags Date: Tue, 12 Jan 2021 12:06:34 +0100 Message-Id: <20210112110647.627783-7-a.darwish@linutronix.de> In-Reply-To: <20210112110647.627783-1-a.darwish@linutronix.de> References: <20210112110647.627783-1-a.darwish@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the new libsas event notifiers API, which requires callers to explicitly pass the gfp_t memory allocation flags. libsas sas_notify_port_event() is called from isci_port_link_up(). Below is the context analysis for all of its call chains: host.c: isci_host_init() (@) spin_lock_irq(isci_host::scic_lock) -> sci_controller_initialize(), atomic (*) -> port_config.c: sci_port_configuration_agent_initialize() -> sci_mpc_agent_validate_phy_configuration() -> port.c: sci_port_add_phy() -> sci_port_general_link_up_handler() -> sci_port_activate_phy() -> isci_port_link_up() port_config.c: apc_agent_timeout(), atomic, timer callback (*) -> sci_apc_agent_configure_ports() -> port.c: sci_port_add_phy() -> sci_port_general_link_up_handler() -> sci_port_activate_phy() -> isci_port_link_up() phy.c: enter SCI state: *SCI_PHY_SUB_FINAL* # Cont. from [1] -> phy.c: sci_phy_starting_final_substate_enter() -> phy.c: sci_change_state(SCI_PHY_READY) -> enter SCI state: *SCI_PHY_READY* -> phy.c: sci_phy_ready_state_enter() -> host.c: sci_controller_link_up() -> .link_up_handler() == port_config.c: sci_apc_agent_link_up() -> port.c: sci_port_link_up() -> (continue at [A]) == port_config.c: sci_mpc_agent_link_up() -> port.c: sci_port_link_up() -> (continue at [A]) port_config.c: mpc_agent_timeout(), atomic, timer callback (*) spin_lock_irqsave(isci_host::scic_lock, ) -> ->link_up_handler() == port_config.c: sci_apc_agent_link_up() -> port.c: sci_port_link_up() -> (continue at [A]) == port_config.c: sci_mpc_agent_link_up() -> port.c: sci_port_link_up() -> (continue at [A]) [A] port.c: sci_port_link_up() -> sci_port_activate_phy() -> isci_port_link_up() -> sci_port_general_link_up_handler() -> sci_port_activate_phy() -> isci_port_link_up() [1] Call chains for entering SCI state: *SCI_PHY_SUB_FINAL* ----------------------------------------------------------- host.c: power_control_timeout(), atomic, timer callback (*) spin_lock_irqsave(isci_host::scic_lock, ) -> phy.c: sci_phy_consume_power_handler() -> phy.c: sci_change_state(SCI_PHY_SUB_FINAL) host.c: sci_controller_error_handler(): atomic, irq handler (*) OR host.c: sci_controller_completion_handler(), atomic, tasklet (*) -> sci_controller_process_completions() -> sci_controller_unsolicited_frame() -> phy.c: sci_phy_frame_handler() -> sci_change_state(SCI_PHY_SUB_AWAIT_SAS_POWER) -> sci_phy_starting_await_sas_power_substate_enter() -> host.c: sci_controller_power_control_queue_insert() -> phy.c: sci_phy_consume_power_handler() -> sci_change_state(SCI_PHY_SUB_FINAL) -> sci_change_state(SCI_PHY_SUB_FINAL) -> sci_controller_event_completion() -> phy.c: sci_phy_event_handler() -> sci_phy_start_sata_link_training() -> sci_change_state(SCI_PHY_SUB_AWAIT_SATA_POWER) -> sci_phy_starting_await_sata_power_substate_enter -> host.c: sci_controller_power_control_queue_insert() -> phy.c: sci_phy_consume_power_handler() -> sci_change_state(SCI_PHY_SUB_FINAL) As can be seen from the "(*)" markers above, all the call-chains are atomic. Pass GFP_ATOMIC to libsas port event notifier. Note, the now-replaced libsas APIs used in_interrupt() to implicitly decide which memory allocation type to use. This was only partially correct, as it fails to choose the correct GFP flags when just preemption or interrupts are disabled. Such buggy code paths are marked with "(@)" in the call chains above. Fixes: 1c393b970e0f ("scsi: libsas: Use dynamic alloced work to avoid sas event lost") Signed-off-by: Ahmed S. Darwish Cc: Artur Paszkiewicz --- drivers/scsi/isci/port.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c index a3c58718c260..10136ae466e2 100644 --- a/drivers/scsi/isci/port.c +++ b/drivers/scsi/isci/port.c @@ -223,7 +223,8 @@ static void isci_port_link_up(struct isci_host *isci_host, /* Notify libsas that we have an address frame, if indeed * we've found an SSP, SMP, or STP target */ if (success) - sas_notify_port_event(&iphy->sas_phy, PORTE_BYTES_DMAED); + sas_notify_port_event_gfp(&iphy->sas_phy, + PORTE_BYTES_DMAED, GFP_ATOMIC); } -- 2.30.0