Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp54903ybt; Tue, 16 Jun 2020 16:22:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPNnq+P1lae6Ji62t2YVx9okcAwDzFCWK3lx7uua7AheOWhC9EieyrGT7hlRD3SlnsIy4U X-Received: by 2002:a17:906:5602:: with SMTP id f2mr4799010ejq.381.1592349769389; Tue, 16 Jun 2020 16:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592349769; cv=none; d=google.com; s=arc-20160816; b=dO5yNAmzdA1UcRrCgbiOdiBIcVxUo6+ETTk7mQa2o7hPZQaITZx/uGMhh4ujuKDkZA CbamVk3knwYACCuxgyhVlwD/XeUu4m7S7QQmtqjNhLenKmoHLYmPleQV/qFzIuCEfFCA /N2JzlbPrhQB4X6FS7Jmr5ZlwxoTcj5yNAX6Std+qOaRnt8R3LNgXHWpTStuc0LGE9sg awrPLOEBkQl5a5WoQ6yB5pvJ6ObqMCPZWnRjZFPotGVhtmgCz5VTAje9hgTkOPLr2KWt NGej0kO7uNDKlEKpHurHm0jsoV4jeCjRexj7br4gAdMlXMXo4rd3KfeXNn55ZdvUDflJ 1+2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=SREc4JqXXmsiMICJdodX5oHbG9y4JPRA4xAPKXsJKjg=; b=MPPDb7n+YDAmapb1sAVJ3mbH/SPoH/8gnZmb9vTR/V/s/qJGfgOMiuinV5RBDf0xdh Rl7aKCmUqNu6jJo6A4USrdt3Wcui9PD9IEKisGSL09GZwKY/qDG5UwHhQRpLMgjDAiD0 O/GJwc98JY5HUKEx2G/NOXxJGPWz+1IhEzlWSsiQfnj2OzE702Bjw0bDvThYoynidIXx jmAQsHi4RwAXbtoaZy8M+TWck0lxcIEu2YrE82zhdXLB46U7EjoGEVS4E0X/syezEfse A3v8SEOzh8m1W800yIGfvagzmhpdLoC2cVWosWOI9zXvXJHDJyMb2iD/I6fPiBVAF49d Zrww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D7HZDgKl; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o3si12380608eje.632.2020.06.16.16.22.27; Tue, 16 Jun 2020 16:22:49 -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; dkim=pass header.i=@kernel.org header.s=default header.b=D7HZDgKl; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726500AbgFPXUW (ORCPT + 99 others); Tue, 16 Jun 2020 19:20:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:39738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725849AbgFPXUV (ORCPT ); Tue, 16 Jun 2020 19:20:21 -0400 Received: from localhost (mobile-166-170-222-206.mycingular.net [166.170.222.206]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B618A207DD; Tue, 16 Jun 2020 23:20:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592349621; bh=tiK4KMdA62onp2wByWby+/bwJDYFvHk4Oek1Xrw3dFA=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=D7HZDgKlntaC82ZPfQik/dwZOJzJT8jigSpJ6AyIV8lHA6Cg/pM1zhcrNrtBna2A7 kwoDrlCmjaOCGTlzlQzpNBUXNCxV/ZBZyNFuk9Yb6KlzTl7Us1ydVRQaEVUwryEqso wVt0aaNxTPk4+CMop//V+SdFwLsaSU0gEfDhcg3E= Date: Tue, 16 Jun 2020 18:20:19 -0500 From: Bjorn Helgaas To: Shiju Jose Cc: linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, rjw@rjwysocki.net, bp@alien8.de, james.morse@arm.com, lenb@kernel.org, tony.luck@intel.com, dan.carpenter@oracle.com, zhangliguang@linux.alibaba.com, andriy.shevchenko@linux.intel.com, wangkefeng.wang@huawei.com, jroedel@suse.de, yangyicong@hisilicon.com, jonathan.cameron@huawei.com, tanxiaofei@huawei.com Subject: Re: [PATCH v9 2/2] PCI: hip: Add handling of HiSilicon HIP PCIe controller errors Message-ID: <20200616232019.GA1987909@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200615101552.802-3-shiju.jose@huawei.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 15, 2020 at 11:15:52AM +0100, Shiju Jose wrote: > From: Yicong Yang > > The HiSilicon HIP PCIe controller is capable of handling errors > on root port and perform port reset separately at each root port. > > Add error handling driver for HIP PCIe controller to log > and report recoverable errors. Perform root port reset and restore > link status after the recovery. > > Following are some of the PCIe controller's recoverable errors > 1. completion transmission timeout error. > 2. CRS retry counter over the threshold error. > 3. ECC 2 bit errors > 4. AXI bresponse/rresponse errors etc. > +static int hisi_pcie_notify_error(struct notifier_block *nb, > + unsigned long event, void *data) > +{ > + struct acpi_hest_generic_data *gdata = data; > + const struct hisi_pcie_error_data *error_data = > + acpi_hest_get_payload(gdata); > + struct hisi_pcie_error_private *priv = > + container_of(nb, struct hisi_pcie_error_private, nb); > + struct platform_device *pdev = priv->pdev; > + struct device *dev = &pdev->dev; > + u8 socket; > + > + if (device_property_read_u8(dev, "socket", &socket)) > + return NOTIFY_DONE; > + > + if (!guid_equal((guid_t *)gdata->section_type, &hisi_pcie_sec_type) || > + error_data->socket_id != socket) > + return NOTIFY_DONE; I think you have to verify the GUID first before you can even safely extract a struct hisi_pcie_error_private from the payload: if (!guid_equal(...)) return NOTIFY_DONE; priv = container_of(nb, struct hisi_pcie_error_private, nb); pdev = priv->pdev; dev = &pdev->dev; if (device_property_read_u8(dev, "socket", &socket)) return NOTIFY_DONE; if (error_data->socket_id != socket) return NOTIFY_DONE; > + hisi_pcie_handle_error(pdev, error_data); > + > + return NOTIFY_OK; > +}