From patchwork Thu Sep 5 05:42:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riyan Dhiman X-Patchwork-Id: 13791757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7BF5FCD4F54 for ; Thu, 5 Sep 2024 05:45:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=ZbsO7GDIIJTt0xgKGCjBgrCED+h3LnKu0qaWwuQvabM=; b=wcr8ThX0naITLmzUXG0NWOplxo jyzLjtfhF90shOtXE7oUaKRgxUPMCvlIltvM3/cX+TXbqhnyk2b3/zXybwtOBF/zWqSFRlGb7Ww2i scx6DVXIT/70axzMrIcGS0L17fzix4naFB5WI8wr8T1cL3dYWMxkJLsNROaHeCpPtxQ5+n7I02whQ UNbRaf76s4Ft7lIfjcUZRE7wULf5gm9HR+AxuZA3fNatnsxjsrT9C98ixIQwjM/P4D+1yd4bb24/i HRDKwnxhfNBsLwYt594U6AXsPfPf2hi/gTKIX5bfCMA2QEVktB/7jc8Hdt/+SoK5SPT2cbiBrqrLD dA0ifeIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm5Ip-000000074rk-2ieL; Thu, 05 Sep 2024 05:45:07 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm5Hr-000000074jE-49uh for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 05:44:09 +0000 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-2d88690837eso285984a91.2 for ; Wed, 04 Sep 2024 22:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725515047; x=1726119847; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZbsO7GDIIJTt0xgKGCjBgrCED+h3LnKu0qaWwuQvabM=; b=jnvINwKajrkyXhX/XlpUSgG3N0TZBKRo9XYxXSQEmNLnriKHV2UkdQPZJbmHXj3rWq I1RnsaDs0ys0XLEuu1K9uhBfUqPa8Y4U5ajmPf67sbIjIs4tctIoxY+/1avJvFZiZrfb f96MYsuI8Bpc+qxjgIo9UtPz7prpW/RtzpAEHeQ+YYj856UXMVjVKV4vHMI/HvVLw41d cUUSegIE54gvnitjqdMUXSq6qHLXMl84wjML9k6IS0ON/LwGsZTBLEFzezQpLQ5WtTtF RHD01rM+7NZvZ6tErAKhX2lV2cBlcrv2RdqlFcRTndrS3+4g1aFC96MYGnFCKfbOr127 S99w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725515047; x=1726119847; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZbsO7GDIIJTt0xgKGCjBgrCED+h3LnKu0qaWwuQvabM=; b=u2jSpYfUy+E9mYPzsupql+JtOVexSbiq0jt/yvLWDUI3jSqUQu/RkfDshpavWvpDTQ oUZxUUAFsmfmB+0TrDQLn3B0GfBnSBZp2gf+no/Q/bNojGfycG57NK5o3rdIgnGzoVYO JrXrH21k/jLazGKbkAS/DiwrGhsPHz46ySncmtLX2GNPPjUF0lFlmyml75iGkLrpfe+s YbipSlGYYNM606X3X8XXTev1+epLlVzkGeWlS7g8qagNyDg8xVqtqeZ7IU0hinjCDCkw IGtQFjJQwyguaEzCNq00IJR9+0fOlDnH4uTKJaKPzCTm2rcgmTOcwK9owRev3Gfd4UZe KSmQ== X-Forwarded-Encrypted: i=1; AJvYcCVrfJkW4IoIMIG1DzavNB0GPlbj9HLwIJ1p/h7iDVt4f0beer7SQNJP7pvVjUn/mBj/oKO/5WOELbd7SIN8rBIG@lists.infradead.org X-Gm-Message-State: AOJu0Yx/9XjciB1y/hJmK15r3IoT2UOebwiTs5D5Z5NM7OQJHI/qltIn HOxiB6PS9RmGgUR08h1eiuutebGAoF53b13Sxr7AZ5Gz8atyKWUP X-Google-Smtp-Source: AGHT+IFREtDh3v/rJbVgKE66ieWm7HhiQ791rRKVF2ym8Umg9iu1Hx/8lKh3w16vChXjPVOd1srCbg== X-Received: by 2002:a17:90b:3e84:b0:2da:5156:1241 with SMTP id 98e67ed59e1d1-2da62fddceamr8295212a91.16.1725515046445; Wed, 04 Sep 2024 22:44:06 -0700 (PDT) Received: from fedora.. ([106.219.166.153]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2da63ac4ea8sm4930614a91.21.2024.09.04.22.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 22:44:06 -0700 (PDT) From: Riyan Dhiman To: hongxing.zhu@nxp.com, l.stach@pengutronix.de, lpieralisi@kernel.org, bhelgaas@google.com Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, Riyan Dhiman Subject: [PATCH next] PCI: imx6: Add error handling in imx_pcie_cpu_addr_fixup() Date: Thu, 5 Sep 2024 11:12:55 +0530 Message-ID: <20240905054255.126676-1-riyandhiman14@gmail.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240904_224408_052527_52F231B0 X-CRM114-Status: GOOD ( 13.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Added error handling to the imx_pcie_cpu_addr_fixup function for cases where the memory window retrieval fails. The initial implementation did not have error handling, and the function simply returned cpu_addr without checking for failure conditions. I have added -0ULL as a error return code but what should be the ideal return code for error handling in this function, given the u64 return type? Common approaches include returning ~0ULL or another invalid address value, but clarification on best practices would be appreciated. Signed-off-by: Riyan Dhiman --- Compile tested only. I am new to the PCI subsystem and not sure how to test these modules. Do I need dedicated hardware, or is there another way to test these changes? drivers/pci/controller/dwc/pci-imx6.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 0dbc333adcff..6af39852d2c2 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -1023,6 +1023,10 @@ static u64 imx_pcie_cpu_addr_fixup(struct dw_pcie *pcie, u64 cpu_addr) return cpu_addr; entry = resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM); + if(!entry) { + dev_err(pcie->dev, "Unable to get memory window."); + return -0ULL; + } offset = entry->offset; return (cpu_addr - offset);