From patchwork Sat Mar 23 01:53:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10866703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45E6A18EC for ; Sat, 23 Mar 2019 01:54:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39DA82A503 for ; Sat, 23 Mar 2019 01:54:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DB812A551; Sat, 23 Mar 2019 01:54:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3733C2A528 for ; Sat, 23 Mar 2019 01:54:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728175AbfCWByN (ORCPT ); Fri, 22 Mar 2019 21:54:13 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:38225 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728136AbfCWByN (ORCPT ); Fri, 22 Mar 2019 21:54:13 -0400 Received: by mail-wr1-f65.google.com with SMTP id g12so4205748wrm.5; Fri, 22 Mar 2019 18:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DYbg+Rd5CZUA/IeYEIt0PqnPXP6HNU4KEIYd+8v11jI=; b=FyiYCSFX7kLkchey/QjFGPVq1OREFV+LNqeI6v8XClCwWuf6dlKo2NCoMsoan3CT0N WwbGI0bG3MsbWEyfOHUze/TZplki+ShyAsDn/I+C1yBDOHgho30tfg29lZfo8L5lHiBK WOHcOtTOdI7abrp7VFSBza1VE9NCnU3U5+yI8b3arqV6hxz9/DHzWJ7v9wsN/HUKk3EU bSGOBI4PBboFlr+l1sUWsU3CnD7yVcrMmIEFhm/HTRlaaK/zF2fY5/NDWE2Dry/jWQrR YB6QzLyLUcapgny7ouEBWxP1nY3D+wyjlpxny2dEsgN1jEpsmEP/2bLoSBfFPkJQN0sa DK1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DYbg+Rd5CZUA/IeYEIt0PqnPXP6HNU4KEIYd+8v11jI=; b=l0Ivh6k1hHOWp27aN1FC1UGr9z5D9KkyZHjq5kDFJIDBy8UxGFlJMPxguBh7y/w5FK 0aPX2G83EEheOKQzXWcpBIxsn2rnYtlEzruXfY+wnAy1HXFqVOaZKW02KDUt8gYVbgAY ph3nhx5avGCK6EDK5GvHh5Wv+9kHFsc1iRi8dNPzVBimWsiTp/OfRJYAD4B9vqFeN/zU bSReNbwxoBxrxanaBhK7TzyhrEciA+QU3DmPTplgz+12S40R+96Yad6QwprfxdRZb3gH jkUkk2o6v89BUB1RycNGEL7hmY1jRDiCgaeP4jFnkf9/zSoCXQsejaTShfZ3wCAEdFR+ 5XkA== X-Gm-Message-State: APjAAAUlL+nrpzPsWDPNBLdegYbEZuOjr/ocgpswBPGgBJ1/yDh2X0Ur QpQlFeLQfZveaJO3A5nssKDmtdDI X-Google-Smtp-Source: APXvYqz51rlmwWJ0haKM8EX4bws4mViTVxRG7/fzfSoObbA2bz0/oLIUHo4DTCwy6d6vJw7He5s0ow== X-Received: by 2002:adf:cd90:: with SMTP id q16mr8080155wrj.75.1553306050911; Fri, 22 Mar 2019 18:54:10 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id y192sm25433050wmc.6.2019.03.22.18.54.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 18:54:09 -0700 (PDT) From: marek.vasut@gmail.com To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org, Wolfram Sang Subject: [PATCH V3 1/6] PCI: rcar: Clean up remaining macros defining bits Date: Sat, 23 Mar 2019 02:53:54 +0100 Message-Id: <20190323015359.7231-1-marek.vasut@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marek Vasut Replace macros using constants with BIT()s instead, no functional change. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org To: linux-pci@vger.kernel.org Reviewed-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven --- V2: Bundle this patch with other cleanups before resending V3: Add Wolfram's R-B --- drivers/pci/controller/pcie-rcar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c index c8febb009454..5b8736f0cd6b 100644 --- a/drivers/pci/controller/pcie-rcar.c +++ b/drivers/pci/controller/pcie-rcar.c @@ -46,14 +46,14 @@ /* Transfer control */ #define PCIETCTLR 0x02000 -#define CFINIT 1 +#define CFINIT BIT(0) #define PCIETSTR 0x02004 -#define DATA_LINK_ACTIVE 1 +#define DATA_LINK_ACTIVE BIT(0) #define PCIEERRFR 0x02020 #define UNSUPPORTED_REQUEST BIT(4) #define PCIEMSIFR 0x02044 #define PCIEMSIALR 0x02048 -#define MSIFE 1 +#define MSIFE BIT(0) #define PCIEMSIAUR 0x0204c #define PCIEMSIIER 0x02050 From patchwork Sat Mar 23 01:53:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10866701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F01BE925 for ; Sat, 23 Mar 2019 01:54:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2D452A503 for ; Sat, 23 Mar 2019 01:54:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D43A22A632; Sat, 23 Mar 2019 01:54:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B4E32A551 for ; Sat, 23 Mar 2019 01:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728185AbfCWByO (ORCPT ); Fri, 22 Mar 2019 21:54:14 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:41525 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728136AbfCWByO (ORCPT ); Fri, 22 Mar 2019 21:54:14 -0400 Received: by mail-wr1-f67.google.com with SMTP id p1so4186364wrs.8; Fri, 22 Mar 2019 18:54:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jSrlccwhQwc3GzuUl1Q5/05D6DwWtcM1QO2IngsuJg8=; b=mZRox8/OZ6wbRPY56UM4jXNmNS2UXR9GcczYNxXFSTZgTtP7oFoahqV4xbiYMClZou hKucxOaV2m8XXlU/UsHXawNn+htyPRIaluxfSwoDfzrcNDzO8j+T/cvuYZ+OHt+2wzvU aWcMVNlqeGUACaatXCDK95q1eIMiy8mCorkTC9N3G/laysvSErtsey5dLNP24lVwMLzM 3eTiekhF6uukENghKxzlHi+h5hLDOAtdkjLzbqgvippmliM/j/MFcw4ThGTt60CU+vuq Ufqy0oMvd8Nu6KbgAGBBSqZC8/Ei4P56ZL5+3IheYhKv7lhBhOiJ/HKdAHxakye1iFwv mdJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jSrlccwhQwc3GzuUl1Q5/05D6DwWtcM1QO2IngsuJg8=; b=iE6Uys4s5GaYu6yCHsRPcP8VCX2WOfw2lsGdZC8f8VW3tm0QPoPujAZc2Cu30hH1Ct LywJdSR6y+adOFkbRF8tkHzE8CinTadOQwkYEPymkKdi01e/To9n4wKtpBs0yjVPBANd 5DWql6RKNsxBfxG5OMCDVdg/riqyYoMO+iIOANzNtI9fXShud3b5k3DBOT9xKLRR8D/+ UC5RzTaMVI8V4bIAND46Zb1GLT/0eoe0lp7KYfS92QWWfPzDp0UaaeF2AExHe7vFFWqw jU+bNR6v5f9e9okWIIXRmGhi+wsAuontdKLAntuevq7ivNyUimYHQSNBwNthCHDwWS37 eRYA== X-Gm-Message-State: APjAAAVdw5kB4zv2MJTD87Tnnm13VB7E3qsoSPqCNsUl15/BLjuTWO/M Pr4uB9IZrCAqkFZr+2ebRkcXJ+x6 X-Google-Smtp-Source: APXvYqzUKJyqPc6ZyxLqylideCsJwCILEjY4iN2ZG6KopPLcTfPk74ywB7QSAhuXNbIxSRquOWkztA== X-Received: by 2002:adf:db10:: with SMTP id s16mr224429wri.181.1553306052507; Fri, 22 Mar 2019 18:54:12 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id y192sm25433050wmc.6.2019.03.22.18.54.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 18:54:11 -0700 (PDT) From: marek.vasut@gmail.com To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org, Wolfram Sang Subject: [PATCH V3 2/6] PCI: rcar: Replace unsigned long with u32 in register accessors Date: Sat, 23 Mar 2019 02:53:55 +0100 Message-Id: <20190323015359.7231-2-marek.vasut@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190323015359.7231-1-marek.vasut@gmail.com> References: <20190323015359.7231-1-marek.vasut@gmail.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marek Vasut Replace unsigned long with u32 in register accessor functions, since they access 32bit registers. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org To: linux-pci@vger.kernel.org Reviewed-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven --- V2: Bundle this patch with other cleanups before resending V3: Add Wolfram's R-B --- drivers/pci/controller/pcie-rcar.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c index 5b8736f0cd6b..1408c8aa758b 100644 --- a/drivers/pci/controller/pcie-rcar.c +++ b/drivers/pci/controller/pcie-rcar.c @@ -152,14 +152,12 @@ struct rcar_pcie { struct rcar_msi msi; }; -static void rcar_pci_write_reg(struct rcar_pcie *pcie, unsigned long val, - unsigned long reg) +static void rcar_pci_write_reg(struct rcar_pcie *pcie, u32 val, u32 reg) { writel(val, pcie->base + reg); } -static unsigned long rcar_pci_read_reg(struct rcar_pcie *pcie, - unsigned long reg) +static u32 rcar_pci_read_reg(struct rcar_pcie *pcie, u32 reg) { return readl(pcie->base + reg); } From patchwork Sat Mar 23 01:53:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10866707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C66A71575 for ; Sat, 23 Mar 2019 01:54:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B75FB2A503 for ; Sat, 23 Mar 2019 01:54:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FC612A528; Sat, 23 Mar 2019 01:54:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CE162A528 for ; Sat, 23 Mar 2019 01:54:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728227AbfCWByQ (ORCPT ); Fri, 22 Mar 2019 21:54:16 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:38522 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728136AbfCWByQ (ORCPT ); Fri, 22 Mar 2019 21:54:16 -0400 Received: by mail-wm1-f65.google.com with SMTP id a188so3787573wmf.3; Fri, 22 Mar 2019 18:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UsipTrZgTM1L+6C3Gfamb8/OgpqPLp9z3b+nG60Gxxc=; b=Gp7d98lZRO2i90z8s1xUmNjlyLRCMu7knySJ0MbMyew7MboX0Drc7uuL1QsEeCIXih PxktEiEzt3AGcIvuR2ylYRuGVne8LIFIw+uC8mEvX7P07SYleSNiebus2zhWYylriLxv VNwkIIX9Tsz+tZQ9prkRH5lOo1vN6t4J5100qEgX0ybW4ECJPjnX33l3o1Mylq1iBb2A LP7pJnWfl/PX2wfWGfNZOhhWerFbKkbBqgf7vZC/mvrFYLYe5Wge9c0m1OX2VQr1kd/x Ot9y0UD+hg0PKDku4j+b91Ypc52gETRFj2FLGDDU9+KJ/VcWSkjLtqu7j3FpMAIkyU1X q0Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UsipTrZgTM1L+6C3Gfamb8/OgpqPLp9z3b+nG60Gxxc=; b=i5lUXeObmFGrDU8A+FbnObkexZH+6kK4NKp5Zgt0EHJfvGVzh6W8Rpn0HXL5uleZaM 4KG6RgFniJmpASEFBysCPBSMxmiOeV6diImJqrz3erflhH6hJGLEwkgQ7nSWGcDXdLIM ZvhEwGHwOQ2w9hJzV5wfr2ICT+G72qFvPp6szSudGx+OeN1NI70vrkrrG78Tbviwrj2Q 70zl6gLANnSG9ToqpqzkEbUXouwdnZ2ZK2Ag23heapQhSywTSc6suKhIKW4V5LNIY6pv FGx1ZQ3dmJ8vVBcyiiT8Q5RL0XXaJBiJWQ8/OvhqWL8DwGP8Uem8/CcQqoe7tPbb56kj dn/w== X-Gm-Message-State: APjAAAXyN+UmNAZ/ROZEhlxjqOHIEpG6W+qXGR219xUzdvga7NhM4NWC CbiqWPNCvr+4Qw79b6knaGpqlBHX X-Google-Smtp-Source: APXvYqzkrCU11kdrweRz871xGRzGH062sL+QY9xTteUQr5rPyABPp0p1auRu2/GfuYsoA/K8ujRrMg== X-Received: by 2002:a1c:6c17:: with SMTP id h23mr4643207wmc.122.1553306054121; Fri, 22 Mar 2019 18:54:14 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id y192sm25433050wmc.6.2019.03.22.18.54.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 18:54:13 -0700 (PDT) From: marek.vasut@gmail.com To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH V3 3/6] PCI: rcar: Replace various variable types with unsigned ones for register values Date: Sat, 23 Mar 2019 02:53:56 +0100 Message-Id: <20190323015359.7231-3-marek.vasut@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190323015359.7231-1-marek.vasut@gmail.com> References: <20190323015359.7231-1-marek.vasut@gmail.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marek Vasut Replace various variable types with u32 or unsigned int type for variables holding register values, since the registers are 32bit. Note that rcar_pcie_msi_irq() still uses various variable types because both find_first_bit() and __fls() require various variable types as an argument. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org To: linux-pci@vger.kernel.org Reviewed-by: Geert Uytterhoeven --- V2: - s@unsigned long@various variable types@ in the commit message - Replace int with unsigned int for the $shift variable - Replace int with unsigned int / u32 in rcar_pcie_config_access() V3: - Change shift from u32 to unsigned int - Change addr and data in phy_write_reg() from unsigned int to u32 --- drivers/pci/controller/pcie-rcar.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c index 1408c8aa758b..a2d3855b15ea 100644 --- a/drivers/pci/controller/pcie-rcar.c +++ b/drivers/pci/controller/pcie-rcar.c @@ -169,7 +169,7 @@ enum { static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data) { - int shift = 8 * (where & 3); + unsigned int shift = 8 * (where & 3); u32 val = rcar_pci_read_reg(pcie, where & ~3); val &= ~(mask << shift); @@ -179,7 +179,7 @@ static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data) static u32 rcar_read_conf(struct rcar_pcie *pcie, int where) { - int shift = 8 * (where & 3); + unsigned int shift = 8 * (where & 3); u32 val = rcar_pci_read_reg(pcie, where & ~3); return val >> shift; @@ -190,7 +190,8 @@ static int rcar_pcie_config_access(struct rcar_pcie *pcie, unsigned char access_type, struct pci_bus *bus, unsigned int devfn, int where, u32 *data) { - int dev, func, reg, index; + unsigned int dev, func, index; + u32 reg; dev = PCI_SLOT(devfn); func = PCI_FUNC(devfn); @@ -294,8 +295,9 @@ static int rcar_pcie_write_conf(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val) { struct rcar_pcie *pcie = bus->sysdata; - int shift, ret; + unsigned int shift; u32 data; + int ret; ret = rcar_pcie_config_access(pcie, RCAR_PCI_ACCESS_READ, bus, devfn, where, &data); @@ -505,10 +507,10 @@ static int phy_wait_for_ack(struct rcar_pcie *pcie) } static void phy_write_reg(struct rcar_pcie *pcie, - unsigned int rate, unsigned int addr, - unsigned int lane, unsigned int data) + unsigned int rate, u32 addr, + unsigned int lane, u32 data) { - unsigned long phyaddr; + u32 phyaddr; phyaddr = WRITE_CMD | ((rate & 1) << RATE_POS) | @@ -1116,7 +1118,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct rcar_pcie *pcie; - unsigned int data; + u32 data; int err; int (*phy_init_fn)(struct rcar_pcie *); struct pci_host_bridge *bridge; From patchwork Sat Mar 23 01:53:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10866711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E04F1575 for ; Sat, 23 Mar 2019 01:54:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7187C2A503 for ; Sat, 23 Mar 2019 01:54:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 649192A551; Sat, 23 Mar 2019 01:54:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 072F02A503 for ; Sat, 23 Mar 2019 01:54:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728241AbfCWByS (ORCPT ); Fri, 22 Mar 2019 21:54:18 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:38231 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728208AbfCWByR (ORCPT ); Fri, 22 Mar 2019 21:54:17 -0400 Received: by mail-wr1-f67.google.com with SMTP id g12so4205834wrm.5; Fri, 22 Mar 2019 18:54:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hHRXoXedoFz32Oq9DJvcczdt4Z6N3+3d7M9GXrlyl8Y=; b=MAc9PHecybfIfu+F2guxsZemYhXIfaDQ3l/E/5IaeACvqQbxP+meJlsZwSq18mG9an sQw0mY1i40fDyO1Hv2e5488/s3mSnTezG4fKjMlPxYBzqOgAYg7PlZoUUlUH5REZMb8N CgxAG9dleiPZItyFLIDJ5JtlUMaSmMCpLLS0ZxCxU/yQqOo7Ry/QoCWb0wxK+WtOnEye 6QtYi+t8xKEC/BaVtUc6FxCn3wNbKn2tIWG5rfvgsMbgLjE9LOVPZcp+JK7Scl13am2g 00cRlolV1UAthkOZybym/j25CsHLv1+HAYOEGHFHJyxsz6gkkPx7vCii5pUGaLt/4kwk h0YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hHRXoXedoFz32Oq9DJvcczdt4Z6N3+3d7M9GXrlyl8Y=; b=XQm5lIK047mNqFqTT/rGVrsZPN8xoiL0I7XG5qLOPPFjLes9h24edrjkTseKuvjsJc Fm7TH1lqQd8sDRerjWUWkI10WBTQusJwYfWMAI9lMo6gLhvCrFJ3VKLdxZ/HEhj/EU8S Fm/u9MyQKynTYP0CF+tZBnKw4Wyt/TwKOTg+YJcEASHystbZ1vM5rUzN2ciZqaTmvJHk IST4brioZWxg/IHKtaIR5uWIejnYTOefb8/XRvfrZgf/7L62KgO/95I/nnRM1RPkJOgr Ld/KqcbAK9Ap/ZrpxVYX+kyN46ZQb4UyqydtOf45zyWgzoh+N0GMJlExvvuW6f15OCA/ DEjw== X-Gm-Message-State: APjAAAWkG8qUkSlFVGC9yMkUPulK0pQOi8XPUjNttZMYG8jAOM+kO+Ah wPTgi7yxzHB1G1afADqsOCFyg+wi X-Google-Smtp-Source: APXvYqwZrYb+gU+aKbINElN/4hRcNKDcVEKjHPHSe6FGdCdzCtu0PM05rniKxw+kc0qauMEmsrlEYQ== X-Received: by 2002:a5d:4a87:: with SMTP id o7mr3826776wrq.306.1553306055524; Fri, 22 Mar 2019 18:54:15 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id y192sm25433050wmc.6.2019.03.22.18.54.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 18:54:14 -0700 (PDT) From: marek.vasut@gmail.com To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org, Wolfram Sang Subject: [PATCH V3 4/6] PCI: rcar: Replace (8 * n) with (n << 3) Date: Sat, 23 Mar 2019 02:53:57 +0100 Message-Id: <20190323015359.7231-4-marek.vasut@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190323015359.7231-1-marek.vasut@gmail.com> References: <20190323015359.7231-1-marek.vasut@gmail.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marek Vasut Replace (8 * n) with (n << 3) to make bit shift operations consistent. No functional change. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org To: linux-pci@vger.kernel.org Reviewed-by: Wolfram Sang --- V2: Bundle this patch with other cleanups before resending V3: Add Wolfram's R-B --- drivers/pci/controller/pcie-rcar.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c index a2d3855b15ea..f835e4341590 100644 --- a/drivers/pci/controller/pcie-rcar.c +++ b/drivers/pci/controller/pcie-rcar.c @@ -169,7 +169,7 @@ enum { static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data) { - unsigned int shift = 8 * (where & 3); + unsigned int shift = (where & 3) << 3; u32 val = rcar_pci_read_reg(pcie, where & ~3); val &= ~(mask << shift); @@ -179,7 +179,7 @@ static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data) static u32 rcar_read_conf(struct rcar_pcie *pcie, int where) { - unsigned int shift = 8 * (where & 3); + unsigned int shift = (where & 3) << 3; u32 val = rcar_pci_read_reg(pcie, where & ~3); return val >> shift; @@ -280,9 +280,9 @@ static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn, } if (size == 1) - *val = (*val >> (8 * (where & 3))) & 0xff; + *val = (*val >> ((where & 3) << 3)) & 0xff; else if (size == 2) - *val = (*val >> (8 * (where & 2))) & 0xffff; + *val = (*val >> ((where & 2) << 3)) & 0xffff; dev_dbg(&bus->dev, "pcie-config-read: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08lx\n", bus->number, devfn, where, size, (unsigned long)*val); @@ -308,11 +308,11 @@ static int rcar_pcie_write_conf(struct pci_bus *bus, unsigned int devfn, bus->number, devfn, where, size, (unsigned long)val); if (size == 1) { - shift = 8 * (where & 3); + shift = (where & 3) << 3; data &= ~(0xff << shift); data |= ((val & 0xff) << shift); } else if (size == 2) { - shift = 8 * (where & 2); + shift = (where & 2) << 3; data &= ~(0xffff << shift); data |= ((val & 0xffff) << shift); } else From patchwork Sat Mar 23 01:53:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10866715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AD1101575 for ; Sat, 23 Mar 2019 01:54:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0A2E2A503 for ; Sat, 23 Mar 2019 01:54:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94B442A551; Sat, 23 Mar 2019 01:54:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45D392A528 for ; Sat, 23 Mar 2019 01:54:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728208AbfCWByT (ORCPT ); Fri, 22 Mar 2019 21:54:19 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:35843 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728136AbfCWByT (ORCPT ); Fri, 22 Mar 2019 21:54:19 -0400 Received: by mail-wr1-f68.google.com with SMTP id y13so4234365wrd.3; Fri, 22 Mar 2019 18:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y5eS/gN/VqRZFxg/obSwIzyXeP5b5RAZ+JaNHCPQk6Q=; b=OIPHsiKUBJv2FhSwdQi8TMtau0cwPy0E1sTnLbBTlDFoVHoQJL+V8mIXBi9Jb3rvdp is7YScF7p9s0LMuORta2Dk50vmScv86uaFWKxHyD1ADtVNN39/9tp0g5eQDQYKwYoyJf BRaGbYOHTC78mKnJQiQ7TfA8/C75O7YRXwOzcPDb/4VG/cEnD0fgWeOgBCWxmtGvvkNv 2H1A+CQnd23GOm2HmlfFMz2kt7sH14Pw8EQmFOoVpBjKA3tnntoPItAXyfKssb0oHX01 4Mq4jIbc+3C+7KdRp6EgZJcn9SzHEL1p6eCmDQahWm0vSPwYZc0hc8q43bqofgiJJKXx 01Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y5eS/gN/VqRZFxg/obSwIzyXeP5b5RAZ+JaNHCPQk6Q=; b=SZG2E8iGRXg12meT4/v+eVmwtc64vj/Jyeyyuk4Oz1r0gG42dxyVjmuPhaFnpsPyuf YXkzxhyO1AeA9TF2aqJXIcAAQPvCqqINIdnOdq33MGZ2lQ/7ySN7m1bIcgx/7UQMk20t AbtzhHFNw5aEoVlTMXgypI4lb8Z4HAQwUQJ9bBdw2xkAzlpZu3SsSYkM5SZfrR32YGhv 1s5qKu6PeYWYMEq96xIiBC+f+XVC+CRD0xv4DzyRiv7SoJi9KOgtZc1JiGCDx+HM+FWW 4Adz8dEV22pwC47Kqk2orRwlWKV5KsMuwoufXD+u6ITD1hHxdiQ0+LO9cmcFHRpDlAxf nf0Q== X-Gm-Message-State: APjAAAVeR4Wy6iwfPuB+x9oLSpuCr7EyAqsDFH9lkUxsusxsSmVeMjIT OXJxjF+s9+J72fdGjNBjv2ykNw1/ X-Google-Smtp-Source: APXvYqzxzeSsuBWD6dwRZ7B1jy0m4GRoXfkjfx70l0MGfSao0k5Pms1ksYh3+VGhJgvRELIhnd2lJg== X-Received: by 2002:adf:fb04:: with SMTP id c4mr7933023wrr.299.1553306056980; Fri, 22 Mar 2019 18:54:16 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id y192sm25433050wmc.6.2019.03.22.18.54.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 18:54:16 -0700 (PDT) From: marek.vasut@gmail.com To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org, Wolfram Sang Subject: [PATCH V3 5/6] PCI: rcar: Clean up debug messages Date: Sat, 23 Mar 2019 02:53:58 +0100 Message-Id: <20190323015359.7231-5-marek.vasut@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190323015359.7231-1-marek.vasut@gmail.com> References: <20190323015359.7231-1-marek.vasut@gmail.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marek Vasut Drop useless casts from debug messages, they are no longer needed due to the data type cleanup. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org To: linux-pci@vger.kernel.org Reviewed-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang --- V2: - Bundle this patch with other cleanups before resending - Add R-B from Geert V3: Add Wolfram's R-B --- drivers/pci/controller/pcie-rcar.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c index f835e4341590..4d9e68ddcdd9 100644 --- a/drivers/pci/controller/pcie-rcar.c +++ b/drivers/pci/controller/pcie-rcar.c @@ -284,8 +284,8 @@ static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn, else if (size == 2) *val = (*val >> ((where & 2) << 3)) & 0xffff; - dev_dbg(&bus->dev, "pcie-config-read: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08lx\n", - bus->number, devfn, where, size, (unsigned long)*val); + dev_dbg(&bus->dev, "pcie-config-read: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08x\n", + bus->number, devfn, where, size, *val); return ret; } @@ -304,8 +304,8 @@ static int rcar_pcie_write_conf(struct pci_bus *bus, unsigned int devfn, if (ret != PCIBIOS_SUCCESSFUL) return ret; - dev_dbg(&bus->dev, "pcie-config-write: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08lx\n", - bus->number, devfn, where, size, (unsigned long)val); + dev_dbg(&bus->dev, "pcie-config-write: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08x\n", + bus->number, devfn, where, size, val); if (size == 1) { shift = (where & 3) << 3; From patchwork Sat Mar 23 01:53:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10866719 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 918C71575 for ; Sat, 23 Mar 2019 01:54:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 854CD2A503 for ; Sat, 23 Mar 2019 01:54:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 798EB2A551; Sat, 23 Mar 2019 01:54:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CD592A503 for ; Sat, 23 Mar 2019 01:54:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728247AbfCWByV (ORCPT ); Fri, 22 Mar 2019 21:54:21 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53904 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728136AbfCWByU (ORCPT ); Fri, 22 Mar 2019 21:54:20 -0400 Received: by mail-wm1-f66.google.com with SMTP id q16so3785232wmj.3; Fri, 22 Mar 2019 18:54:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M/bqmq1neQ8ZCG+i4HaquxamvGRxXKBsVpujyAjKLpw=; b=aFooEtuTjS3Z09mYGyWOCZuV2CBhfaez6yc/EBpodh3QZz0aeJWHPVxvZr3C9h1SKM 8I6vck3hU+KNpxZoObLe+2klmtHiVGrjxAHAFuV82v2g5fFCZZe/jBlhXTo018LE1sXq 1P/60hTqEAmx0iyd1YxwCoZ+evOKKMjjhEvORiKK5tZ+bUcqUfD2dxDzL8/otG3whXo4 BIMNV/xdsA4BG9bRJJaPMiVbegZgiqcleDAGe9aLZDYQhtBLOo/0DAzAh4AQHOiSg77n FmgzMe1n4OCMvXeRbJnX3LVbu44jYXhpcGioX9OPIzpv4DgVF6dDiRPRKlUZsyn0pku/ cA0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M/bqmq1neQ8ZCG+i4HaquxamvGRxXKBsVpujyAjKLpw=; b=DJS9nkuTVHM3kcKNFWdOWl9zdnRq0XW4QjoJXggZOEwm0iHioiC9Xt8Btuq+uweKfk IfNcbPHAChJC/kdV9T1noU9zf9KaUWHclYBRhnkf3AhRibo7KwrYDiHTDzVprfaM0uQE +JxQD6FzcGX2vcA2DunxWjSekp8cAPaD8DsPaUfel3WCoeNdx1rHEWB2A7RIbfq9waOs RWhpqgFvbLf+x82uwXjzpxbFTYuI78nlvrVOccY4kY4uRO3T2WB7a56ovTlvW/qmzEEc BnIbPqZnXrcetlfHqKzNTI7HqFk6O0htZVFE/KMEZXjQCmQSfjSt/fcplU3O6lTGvJNU hP4g== X-Gm-Message-State: APjAAAXmBtqZm4T3BbbqvHc6qYudSHA7R/4R7oxzFD3Fgbta+1l/zgl0 DjxcSCTobDkX7OJn0mVNBl7cV5ZO X-Google-Smtp-Source: APXvYqx6loSxMLcgbNzr/8clkj6pW6s86PyyWHotgUmoMKolAyR63m3ZIQqtKBp/oCSLhbC67s9nnQ== X-Received: by 2002:a1c:2394:: with SMTP id j142mr4632751wmj.111.1553306058446; Fri, 22 Mar 2019 18:54:18 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id y192sm25433050wmc.6.2019.03.22.18.54.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 18:54:17 -0700 (PDT) From: marek.vasut@gmail.com To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH V3 6/6] PCI: rcar: Fix 64bit MSI message address handling Date: Sat, 23 Mar 2019 02:53:59 +0100 Message-Id: <20190323015359.7231-6-marek.vasut@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190323015359.7231-1-marek.vasut@gmail.com> References: <20190323015359.7231-1-marek.vasut@gmail.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marek Vasut The MSI message address in the RC address space can be 64 bit. The R-Car PCIe RC supports such a 64bit MSI message address as well. The code currently uses virt_to_phys(__get_free_pages()) to obtain a reserved page for the MSI message address, and the return value of which can be a 64 bit physical address on 64 bit system. However, the driver only programs PCIEMSIALR register with the bottom 32 bits of the virt_to_phys(__get_free_pages()) return value and does not program the top 32 bits into PCIEMSIAUR, but rather programs the PCIEMSIAUR register with 0x0. This worked fine on older 32 bit R-Car SoCs, however may fail on new 64 bit R-Car SoCs. Since from a PCIe controller perspective, an inbound MSI is a memory write to a special address (in case of this controller, defined by the value in PCIEMSIAUR:PCIEMSIALR), which triggers an interrupt, but never hits the DRAM _and_ because allocation of an MSI by a PCIe card driver obtains the MSI message address by reading PCIEMSIAUR:PCIEMSIALR in rcar_msi_setup_irqs(), incorrectly programmed PCIEMSIAUR cannot cause memory corruption or other issues. There is however the possibility that if virt_to_phys(__get_free_pages()) returned address above the 32bit boundary _and_ PCIEMSIAUR was programmed to 0x0 _and_ if the system had physical RAM at the address matching the value of PCIEMSIALR, a PCIe card driver could allocate a buffer with a physical address matching the value of PCIEMSIALR and a remote write to such a buffer by a PCIe card would trigger a spurious MSI. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org To: linux-pci@vger.kernel.org Reviewed-by: Geert Uytterhoeven --- V2: - s/it's/its/ in commit message - Add R-B from Geert V3: - Reworded commit message and thus dropped Geerts R-B --- drivers/pci/controller/pcie-rcar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c index 4d9e68ddcdd9..6bedd2167f3c 100644 --- a/drivers/pci/controller/pcie-rcar.c +++ b/drivers/pci/controller/pcie-rcar.c @@ -890,7 +890,7 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) { struct device *dev = pcie->dev; struct rcar_msi *msi = &pcie->msi; - unsigned long base; + phys_addr_t base; int err, i; mutex_init(&msi->lock); @@ -932,7 +932,7 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) base = virt_to_phys((void *)msi->pages); rcar_pci_write_reg(pcie, base | MSIFE, PCIEMSIALR); - rcar_pci_write_reg(pcie, 0, PCIEMSIAUR); + rcar_pci_write_reg(pcie, base >> 32, PCIEMSIAUR); /* enable all MSI interrupts */ rcar_pci_write_reg(pcie, 0xffffffff, PCIEMSIIER);