Received: by 2002:a05:7208:70d5:b0:7f:5597:fa5c with SMTP id q21csp1280526rba; Fri, 22 Mar 2024 09:12:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaEBpSdhMIIdQYacw6TYLt9LLlcEcf5gAOfEC7HaXfECcuHM2wQmtfk7Th+06SXN2U0eEDGDXceA6GO2NdZ1Sv4/KL9DGJbpFbzqJH1A== X-Google-Smtp-Source: AGHT+IEAYRymSVEuOOFaP/jsYYU2iPFKIymItxF9dIEX+aPL+2ahIVZNGujI/m+EAHbCmUA4e6ZI X-Received: by 2002:a05:620a:45a7:b0:78a:317e:b89d with SMTP id bp39-20020a05620a45a700b0078a317eb89dmr3825520qkb.37.1711123920536; Fri, 22 Mar 2024 09:12:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711123920; cv=pass; d=google.com; s=arc-20160816; b=FAsBZV5510rDhUFNXLJVhGgie2dBmND/pD9MrhyvA+Uta9MtmAehissGzKd667UeSM EfsTBMy6vkssM8viDw/t/g7rRqF2C4Gc5Rp6R7lgS/7KfVRzN+mF6q+Ug/T12/pqEh6V 2szHk66yZnug2QSeY1pDR9fGLaiuCAPDLaX4eXXZpa6aJPhMjwkxSTInm5D3gO+PszhZ tQQChJLfIiR9Fg7ZSwumzJGlzUDVSJ4ODnXWyOBIbL+8WWIIILZAKMweU9m4d5Qz08sV JmO2epZqCgdrvL71dPI0UGzRR8pui09KRpvoQ3koP1F/OzKoCAYE94DzYshqyCNGirlV iR2A== 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=U354an2SaQKASCgES6Wpk4Q0RcaffmCwyxFBle0eO28=; fh=0tIhEViLo7PUpyJI/8YvAfn7aU9qwVOIrJ6jkc06K5o=; b=WjamKMl2cgATCKVvJxODn1ilxYIQrdGiDgDjSxzcUvH2AGob9+BCitUesceif0H7+Y ClPGXNt4jeyl7WOWk0dqurM4kPKQXbApRQFe2DEwDX7uMBbWSEQ8ql84c5G+i3T5pO7K kmQfKd+HDhLskCZEhWVolkcKy3R40TiDdZFLai0nsJW98jX1nDsB/N/OCwayg7znAhVF 4EfCdhUafdyWHpcBOJijjM5L2u/EfwSaqOiPJ1XxO6adSjFbdz1o+HsadFu24wS9B+qD IPQtrEfJbH2ioK9D9Rrc/d6XJy168OQimgLKKo6KqHS8q4OhaCI2Z/BvhC4VB5PA6a5A ASOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NzzeQePB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-111760-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111760-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m30-20020a05620a215e00b00789f1127180si2239161qkm.264.2024.03.22.09.12.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 09:12:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111760-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NzzeQePB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-111760-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111760-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id AD3241C22EFA for ; Fri, 22 Mar 2024 16:11:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49C655D75F; Fri, 22 Mar 2024 16:10:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NzzeQePB" 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 464D056B7A; Fri, 22 Mar 2024 16:10:49 +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=1711123849; cv=none; b=ahO/lHpaxWrDvcz5ht07U8Nbziy9+J02DBpYrDLs5is7jnYFGC/hq8zywbkotkC2HzPnHpzbOcHCADmJpY6W+udt1DVaAJ7KdceJKYZe7sRLq3D6qFWiCHMgphRfO70m4BIJ3hBpHnG06QxMDk7H290AbQYBtIP0VOQPI+cUxwA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711123849; c=relaxed/simple; bh=wnXnzIzMjqIeOSx2R+ckSe9WQAcO+DmN0P5bRnwI08Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HAP2F7D65xSmGNzna5/5AhnQbHK3+OzQ67q7yGYpY6IsiFQsLW+16lWzDhOpGtrU1g8lDdU/d1kZKn5+XBIo8zed4I5CyqLw7BKK2fhZimeTEH+CQSIRN45CiBZ+7YFsTcXdIk4i/Lho2b8nzQOUYN0r1sxSts1YEZntWnmX1/U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NzzeQePB; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED6C5C43390; Fri, 22 Mar 2024 16:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711123849; bh=wnXnzIzMjqIeOSx2R+ckSe9WQAcO+DmN0P5bRnwI08Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NzzeQePBQ5WorR+piyK1EUN1fQPTi4wGf+hss+zKlVWLr+TCyYKrL286biy/wewVJ XOBnIt3VVer6985KDVCRpEMy9onAVVqHPYW5HgBdGbRBnMjEF9KIcR8gs25IGqPOBa YmTdj2kg7zmk8De/tNLoBsTbiE8Cuzw7jzMxxq3975TflkJCzzTvMpCJeXnhKTEy7R t/AsNMUNBkS87/PQjCySHfJyWYaYR8RYMharpU1HthE6HH9sqWp0GRMurccC5GElF/ N+fFdo5xlTvul7wELAiOkd0xwZX37PzrDTkNM/8W02C9r5g7yPxKOmKYfY3tsFCgYX 9vRLcUMhYpFgg== Date: Fri, 22 Mar 2024 17:10:43 +0100 From: Niklas Cassel To: Manivannan Sadhasivam Cc: Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Kishon Vijay Abraham I , Thierry Reding , Jonathan Hunter , Jingoo Han , Gustavo Pimentel , linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, mhi@lists.linux.dev, linux-tegra@vger.kernel.org Subject: Re: [PATCH 09/11] PCI: epf-test: Handle Link Down event Message-ID: References: <20240314-pci-epf-rework-v1-0-6134e6c1d491@linaro.org> <20240314-pci-epf-rework-v1-9-6134e6c1d491@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: <20240314-pci-epf-rework-v1-9-6134e6c1d491@linaro.org> On Thu, Mar 14, 2024 at 08:53:48PM +0530, Manivannan Sadhasivam wrote: > As per the PCIe base spec r5.0, section 5.2, Link Down event can happen > under any of the following circumstances: > > 1. Fundamental/Hot reset > 2. Link disable transmission by upstream component > 3. Moving from L2/L3 to L0 > > When the event happens, the EPC driver capable of detecting it may pass the > notification to the EPF driver through link_down() callback in 'struct > pci_epc_bus_event_ops'. > > While the PCIe spec has not defined the actual behavior of the endpoint > when the Link Down event happens, we may assume that atleast the ongoing Nit: s/atleast/at least/ Reviewed-by: Niklas Cassel > transactions need to be stopped as the link won't be active. So let's > cancel the command handler work in the callback implementation > pci_epf_test_link_down(). The work will be started again in > pci_epf_test_link_up() once the link comes back again. > > Signed-off-by: Manivannan Sadhasivam > --- > drivers/pci/endpoint/functions/pci-epf-test.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c > index 84cd47ebac22..97245228c9eb 100644 > --- a/drivers/pci/endpoint/functions/pci-epf-test.c > +++ b/drivers/pci/endpoint/functions/pci-epf-test.c > @@ -823,6 +823,15 @@ static int pci_epf_test_link_up(struct pci_epf *epf) > return 0; > } > > +static int pci_epf_test_link_down(struct pci_epf *epf) > +{ > + struct pci_epf_test *epf_test = epf_get_drvdata(epf); > + > + cancel_delayed_work(&epf_test->cmd_handler); > + > + return 0; > +} > + > static const struct pci_epc_event_ops pci_epf_test_epc_event_ops = { > .init = pci_epf_test_epc_init, > .deinit = pci_epf_test_epc_deinit, > @@ -830,6 +839,7 @@ static const struct pci_epc_event_ops pci_epf_test_epc_event_ops = { > > static const struct pci_epc_bus_event_ops pci_epf_test_bus_event_ops = { > .link_up = pci_epf_test_link_up, > + .link_down = pci_epf_test_link_down, > }; > > static int pci_epf_test_alloc_space(struct pci_epf *epf) > > -- > 2.25.1 >