Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1881290lqp; Mon, 15 Apr 2024 23:50:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVdgbYhXBrEFXCBuG7BiMMmHYjd08A7Um48trVKuWl5/AXO/P2gMK36QnCUM6w9e8ID5Du6GZKD0QYrI2IkZBL5zAzytBQ9dk9spJSsxA== X-Google-Smtp-Source: AGHT+IE85RqQa7AVEJWihIFlyy5uBndDEihNRsD/9RA76b2Nb4HkPeNC8RxM2Z9oJdZ156h8vsKQ X-Received: by 2002:aa7:8890:0:b0:6ed:973d:936 with SMTP id z16-20020aa78890000000b006ed973d0936mr12224025pfe.9.1713250215261; Mon, 15 Apr 2024 23:50:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713250215; cv=pass; d=google.com; s=arc-20160816; b=lKPpbgTv4NIjdmDcN09zKZkWRBqa4pcuYYSPEaiHFqaLtANkY5V+tFuZrMCDNeEW8J nr2iMReCV3lrzb4g54ghHxKIxMWmQgXIutGV63nGhki9E7quLAGflz/fm5ZLjDhifAsP bu5LdnP9PqtAWNoqWahGPlnYY2jULTxBAhPdllUeGd2antS/7sYvMkwGCs+teprMHLxu a5m6EoZY8g9hGZwO8SMId9R4GJLgePI5uub900/YVwrezCcUS6jEWH2KZN5I2Beu+mrN JL+FK8fjIz+T17Elzp7EGUEoJugmTpH3QU9M0xAMZKjouL+HP66F2tJE8j86gUYlmAET ZAjA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3iJc3la+zFu1W8Ew5dA4kT3HI17JcHggkXwwhvshyeM=; fh=D3tiIY2Ho1VozPeVVsb1jcMnLPsTmYOJ1Tq3gsBpw68=; b=j9PLG6amyMi2K33XdHYD75dPSfPAKR9mdJxKfXcrJryKbAqC37uR5WBSMKWtm1bnKI T4M/Y7NU7RUkEcFdYZNLOI7BQhqZHRIBHlLc1uOJM9ovqJh9RKqb6tmJV+b39DH738gG 1c0RDnzQF++8p7o6jM6bdbCF057cAJq6QNByQ3KdLrEBymUBg0tvfPg3OVdz1Ch0UANH xesbPwX0ZQNk5qoctfYu1Oz41yjqNRysV39Et7A4DE9OfrkM3uJAYpeYIY6IE4ukeNaO 43LNjYjSVU00KVagrcLTbhoUfSycUXPeNl/7JEBKP8viy1dvMPIct/QD2mcSuyG5dUGC +j0w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LzS40nkM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-146367-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146367-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id fj30-20020a056a003a1e00b006eabaeda14asi9430263pfb.387.2024.04.15.23.50.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 23:50:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146367-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LzS40nkM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-146367-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146367-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D7A4FB23112 for ; Tue, 16 Apr 2024 06:50:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D2A66F076; Tue, 16 Apr 2024 06:50:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LzS40nkM" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 199BD6BFCF; Tue, 16 Apr 2024 06:49:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713250200; cv=none; b=o4IKgaCRu9yj8wH8CUNdNLyFccRYtngbd9a6uvX5jZIy57Tcf0ATAdBrmMj/ovch3PG+Kh8ExKv8cYRK/ZPV4V56+MBgHj8/AIQpUCv4ISjXNSGS1LMocTuxC6pkZUxHFNzv1qLkjmSORphrnMRoz8wKDvupJMjJ/PY9iJQ8HYs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713250200; c=relaxed/simple; bh=yfX5SuJiKsjZz5T4krQC0RPDEuHfvs/zvmFjAxx/zlY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IYD3iL1tB45ghxcYjZL5hZtApXqQsKcYvC/pOsP0wQTTRPs9OqUcsbC8S1u4U6Jqfqllyq6H8S9BC7UTKoAH+QHfSxc4DUPVDEbF/Nz07ncB1+Sd2UGYUnSUqdl5v5Ja/yclm5GxEyfBcM46CFftIMQgT8M429RY0ieWK509JIA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LzS40nkM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DD27C113CE; Tue, 16 Apr 2024 06:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713250199; bh=yfX5SuJiKsjZz5T4krQC0RPDEuHfvs/zvmFjAxx/zlY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LzS40nkMJsIBoNMyiBYU1dZiU1GtglSAeoOK9Wcywa3dOY58e3mqlh5jo9Uo3Wg2F bgDK0tl59DTrBOygg0MimxmV2SmnnMK3sWaXBhFO/CJhjGPCxtnk5Ia76in1UYvUBK vckfRAEjG0RHpNWyty6mmMfUa+d70IPhKPL2FQaHhubHznn8lySE+KogwTaJ59l1It NTQM+YyatNBircIy0BD3jOigDDKO2b0E8+exBqLDcMGDsa4gWo9HVGWxSrZL8T2Vfr 2sQ0oHzwEEpUKvd/TIIKAKi7z/0bxlEuMynqeleZ7TqaBos8awEksUEIqjQ87iO0QI DAkcQpckpO54w== Date: Tue, 16 Apr 2024 08:49:53 +0200 From: Niklas Cassel To: Manivannan Sadhasivam Cc: Shawn Lin , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Heiko Stuebner , Brian Norris , linux-pci@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mhi@lists.linux.dev, stable@vger.kernel.org, Slark Xiao Subject: Re: [PATCH] PCI: rockchip: Use GPIOD_OUT_LOW flag while requesting ep_gpio Message-ID: References: <20240416-pci-rockchip-perst-fix-v1-1-4800b1d4d954@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240416-pci-rockchip-perst-fix-v1-1-4800b1d4d954@linaro.org> On Tue, Apr 16, 2024 at 11:12:35AM +0530, Manivannan Sadhasivam wrote: > Rockchip platforms use 'GPIO_ACTIVE_HIGH' flag in the devicetree definition > for ep_gpio. This means, whatever the logical value set by the driver for > the ep_gpio, physical line will output the same logic level. > > For instance, > > gpiod_set_value_cansleep(rockchip->ep_gpio, 0); --> Level low > gpiod_set_value_cansleep(rockchip->ep_gpio, 1); --> Level high > > But while requesting the ep_gpio, GPIOD_OUT_HIGH flag is currently used. > Now, this also causes the physical line to output 'high' creating trouble > for endpoint devices during host reboot. > > When host reboot happens, the ep_gpio will initially output 'low' due to > the GPIO getting reset to its POR value. Then during host controller probe, > it will output 'high' due to GPIOD_OUT_HIGH flag. Then during > rockchip_pcie_host_init_port(), it will first output 'low' and then 'high' > indicating the completion of controller initialization. > > On the endpoint side, each output 'low' of ep_gpio is accounted for PERST# > assert and 'high' for PERST# deassert. With the above mentioned flow during > host reboot, endpoint will witness below state changes for PERST#: > > (1) PERST# assert - GPIO POR state > (2) PERST# deassert - GPIOD_OUT_HIGH while requesting GPIO > (3) PERST# assert - rockchip_pcie_host_init_port() > (4) PERST# deassert - rockchip_pcie_host_init_port() > > Now the time interval between (2) and (3) is very short as both happen > during the driver probe(), and this results in a race in the endpoint. > Because, before completing the PERST# deassertion in (2), endpoint got > another PERST# assert in (3). > > A proper way to fix this issue is to change the GPIOD_OUT_HIGH flag in (2) > to GPIOD_OUT_LOW. Because the usual convention is to request the GPIO with > a state corresponding to its 'initial/default' value and let the driver > change the state of the GPIO when required. > > As per that, the ep_gpio should be requested with GPIOD_OUT_LOW as it > corresponds to the POR value of '0' (PERST# assert in the endpoint). Then > the driver can change the state of the ep_gpio later in > rockchip_pcie_host_init_port() as per the initialization sequence. > > This fixes the firmware crash issue in Qcom based modems connected to > Rockpro64 based board. > > Cc: # 4.9 > Reported-by: Slark Xiao > Closes: https://lore.kernel.org/mhi/20240402045647.GG2933@thinkpad/ > Fixes: e77f847df54c ("PCI: rockchip: Add Rockchip PCIe controller support") > Signed-off-by: Manivannan Sadhasivam > --- Reviewed-by: Niklas Cassel I sent a similar fix for the DWC-based rockchip driver a few weeks ago: https://lore.kernel.org/linux-pci/20240327152531.814392-1-cassel@kernel.org/ If your fix is picked up, it would be nice if mine got picked up as well, such that both drivers get fixed. Kind regards, Niklas