From patchwork Wed Aug 26 15:49:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shenwei Wang X-Patchwork-Id: 7077971 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8C98FC05AC for ; Wed, 26 Aug 2015 15:52:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A75C720924 for ; Wed, 26 Aug 2015 15:52:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7430F20815 for ; Wed, 26 Aug 2015 15:52:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUcxm-0002uh-6P; Wed, 26 Aug 2015 15:50:10 +0000 Received: from mail-by2on0124.outbound.protection.outlook.com ([207.46.100.124] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUcxj-0001jo-9F for linux-arm-kernel@lists.infradead.org; Wed, 26 Aug 2015 15:50:08 +0000 Received: from BLUPR0301CA0019.namprd03.prod.outlook.com (10.162.113.157) by CY1PR03MB1376.namprd03.prod.outlook.com (10.163.16.30) with Microsoft SMTP Server (TLS) id 15.1.243.23; Wed, 26 Aug 2015 15:49:45 +0000 Received: from BN1BFFO11FD034.protection.gbl (2a01:111:f400:7c10::1:187) by BLUPR0301CA0019.outlook.office365.com (2a01:111:e400:5259::29) with Microsoft SMTP Server (TLS) id 15.1.256.15 via Frontend Transport; Wed, 26 Aug 2015 15:49:44 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD034.mail.protection.outlook.com (10.58.144.97) with Microsoft SMTP Server (TLS) id 15.1.256.10 via Frontend Transport; Wed, 26 Aug 2015 15:49:43 +0000 Received: from [tx30smr01.am.freescale.net (B38339-11.am.freescale.net [10.81.93.199]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t7QFnfY2001690; Wed, 26 Aug 2015 08:49:43 -0700 From: Shenwei Wang To: , , , Subject: [PATCH 1/1] irqchip: imx-gpcv2: Simplify the implemenation Date: Wed, 26 Aug 2015 10:49:26 -0500 Message-ID: <1440604166-2624-1-git-send-email-shenwei.wang@freescale.com> X-Mailer: git-send-email 2.5.0.rc2 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD034; 1:3tlRrg4tuTMl7NstzKeSZY4NR/yXs+5a/w8NpzCdbCZ+IqvrwA1Qe/VElwsGv+q/Lfq52RPV1MC94CZ+sLeziD6bgYSVCEpdwTXgUkNToF/ogKgbudO1i+tAOjMWu7WMBYWBwkEywXKcc8SvgUra691Xhp6+mMrq7aEUMNqxjNd+l51y7uPUfMFU533cS7Jyy2382f58TiIbFLDaPaMsrFMexjvB8IqofgRv43QJaSyJgJrSHQW1lGDcgAzFR2vOb2ZRQKSm7t+P4Xf124lpEwAmOv8Cj4LUeRJe9DKoOVmqZAuA9Bcr/j4UzcPUz18OZbs7KY5ZZNtvNDIHsLh+TG3VTFNn+dcThhQ9qPnUTcKXZWhOVTJ9lkNrMX6wgLi34CdOzSdUpplLbA86cnjVbcdj3+r0xjYA0rAL/TZY6Uk= X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(3050300001)(339900001)(189002)(199003)(85426001)(104016003)(47776003)(77096005)(68736005)(5007970100001)(87936001)(46102003)(77156002)(92566002)(62966003)(86362001)(2201001)(5003940100001)(64706001)(97736004)(5001830100001)(229853001)(5001920100001)(81156007)(5001770100001)(6806004)(50466002)(189998001)(50226001)(5001860100001)(19580405001)(106466001)(107886002)(48376002)(36756003)(5001960100002)(19580395003)(105606002)(50986999)(4001540100001)(33646002)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR03MB1376; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB1376; 2:v2PiRPtVcGx3RxAy0+C7JlaeaZM5NRRnIpFqw+jgz0CI0fgXNokon7jpylfXknYQ87tKOT1TZFRYwNy7rCsqYGFCNlQZEn3VHemT7gv9Dqi3AhnID+Bfv6Dye+VKQ2dsBlKNOlA/pQxbpIP7CXfVPW53YfQyezN6Vtkw+dmaKpo=; 3:ko8NaAa+0k+Ic8Li9VFlxHBCd5ufGecxIzYjSgWkshmKHiee20D/1Pnir66yJ6LNbRkjn69xmJ2mwJ7N3h+jwYjTy7pG/IKxhZImarGgnH8Mj+orzqvy45iTPlmhSvUKnEl7P1NBMNlRpZUfd958vWaeHyYYH/YPPSimu4muU0qXSU8V4o8NNhWCKZNnIlclQ/tz4MZDWeKTDgHFNQXLVDUvPxdCEqKn8RLmQJ3zKDI=; 25:z/wCdxGBVaRmmoCEFyvijDJ9t43pDmwII5bl/T1hyVu/uiMCK7Q4bFwhwa4gXASmiyvWTPNCIMVa1c0yBNYsG3jJWsAvUBfKmg0i6nv4rXE4n+lDmoCrkJIqRHM7TaIoKpTRR70svcfQXlEqSvbPOz2YbzoPewZm3Oi4JKi0HLgeJGqDComNuzhWAJUgsKDNo1jIBRjI0gSjP/HQxngqLxUA8dgWoXvp26w+gkEadBfUQ9SWjtocJwEoK6F+ttx6XnmLTA4VDywmVx1LS72Ufw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1376; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB1376; 20:YOBFpGH09j1FDIE9e5rYU3/VaPv33cHwE3V3qzMn0ixXyif/mTWeJN06kWuF9pawd6cQj683zHTbvRODFcniNDBN56oWEUcsOkOQdI3AprwbwgokZw417wphVs8RT4ipxyu0qhopl+O0yjOqVS96dv2WXnBnVG0hAsLyBMeK2p/H85eLfRibV6FVu1PqOfIcwuSXbo4HrlZxN0uIHPvGl58UL+A+lxt3mKhyU69FcZ/25t5wCsdul0dX8Z6bavahBogLCLD60L8ebNCg1NnxOVfj3P/Vy/fFcLjhLhaRGHnYYhai5ePyUoTgAEGBm/Idp56iH9fmVovTH1a1s6uM8wcfbGID3x+lgbdFrowAA7Y=; 4:hawLJNwgfp6/ilJU6SBElRG3FKsDhn8cVrb6Ib704b9X8LH+ppQgUAA1BpBoE7QXnFJ3jIf2KubSQrxxqX9ou1CQMr4tXl3YT3WJBEmQXUEex1kNaADBYE9bTzyX6NV1l6NnfevbuLmt+vYNMDB++Hyrc/bZWHr7TdrKxfehcrxap8Dk6K/gmGfLKomgwmTLTgo6rxVKshGzCFCZRH09tv7taUHHhuj0grfqLSazW71HpcccT8loSiscJz/iaRFonpYFX9K/Oi3LECSxiD7bk/+DW7XQgErSszEFzW+v6z/1qAOiLu2sL5Ktlchez73n X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(8121501046)(3002001); SRVR:CY1PR03MB1376; BCL:0; PCL:0; RULEID:; SRVR:CY1PR03MB1376; X-Forefront-PRVS: 0680FADD48 X-Microsoft-Exchange-Diagnostics: =?us-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knxovAbyXqRGmdlm6nNwVOv8pp?= =?us-ascii?Q?s5JNb9jL/3WR6lxNWPciGj7tQqg0W+75NhgDZiPYeQ39EYIgfwFaVkaJ4TLh?= =?us-ascii?Q?jg96Cm5doPZqx3R4NZnZ0tZizoXzmT/jXaYjcOUN9IhlhVXNNZu9Rt45DE1k?= =?us-ascii?Q?ds7bXQQcq4YXCTd9CG2idVr1PEaJALYRXnr9zyNkpCj8iO7Xcvh8+OiSQms3?= =?us-ascii?Q?EOomEF0ByimIuoTa/bKPx0FFyrL5JT+45wPASZYo2upKLD4W2Z7yCXXXrCRl?= =?us-ascii?Q?PgdUDr66Je79n8xfEBRNxegYk38Ki6p75zaxFJaqQIRI1XILPGxMEMcYUamq?= =?us-ascii?Q?1wTnVR5ERI5YFXx3olOi/y6/qGvRzX9oWOgHck/Z+LqHF7sGypMkmPb0g=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB1376; 5:blVGnouOrXIK7IGTWQXZAExKl8f3wcvstjQ+SJGO7yF0kXKEuIwWil4MxG36OSxvCCwiKPNqOYmQLCljj2q3twjlhzTwLSfwSC9mpIps6y+Qft5FgQmU0J0ZFASfFmAT7fhwET2RiODK68i/gTHV8g==; 24:EvdGw+bA32750b69b6ZkvYCEEb8RnnsbmHwfuoUyvY9Po/ZO1D0CO8jvx/FD3aIexGU3SwZ5KgviaAclcVPfHT+fscShWp/GOpqQ+f5CAOk=; 20:fvPpAo+4P2bC6fZ1tN3DVIin+ev5utOWqvjZADqBHQnjMoTJSBw+hpa7XBRBHNUTpv1u5+e1cNg5hihZscZ2Og== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2015 15:49:43.9362 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR03MB1376 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150826_085007_489508_9EB3C079 X-CRM114-Status: GOOD ( 24.35 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: b20788@freescale.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Based on Sudeep Holla's review comments, the implementation can be simplified by using the two flags: IRQCHIP_SKIP_SET_WAKE and IRQCHIP_MASK_ON_SUSPEND. This patch enables the flags in the struct irq_chip and removes the unnecessory syscore_ops callbacks. Signed-off-by: Shenwei Wang Reviewed-by: Sudeep Holla --- drivers/irqchip/irq-imx-gpcv2.c | 83 +++++++---------------------------------- 1 file changed, 13 insertions(+), 70 deletions(-) diff --git a/drivers/irqchip/irq-imx-gpcv2.c b/drivers/irqchip/irq-imx-gpcv2.c index 4a97afa..e25df78 100644 --- a/drivers/irqchip/irq-imx-gpcv2.c +++ b/drivers/irqchip/irq-imx-gpcv2.c @@ -22,7 +22,6 @@ struct gpcv2_irqchip_data { struct raw_spinlock rlock; void __iomem *gpc_base; u32 wakeup_sources[IMR_NUM]; - u32 saved_irq_mask[IMR_NUM]; u32 cpu2wakeup; }; @@ -30,79 +29,25 @@ static struct gpcv2_irqchip_data *imx_gpcv2_instance; u32 imx_gpcv2_get_wakeup_source(u32 **sources) { - if (!imx_gpcv2_instance) + struct gpcv2_irqchip_data *cd; + void __iomem *reg; + int i; + + cd = imx_gpcv2_instance; + if (!cd) return 0; + for (i = 0; i < IMR_NUM; i++) { + reg = cd->gpc_base + cd->cpu2wakeup + i * 4; + cd->wakeup_sources[i] = readl_relaxed(reg); + } + if (sources) - *sources = imx_gpcv2_instance->wakeup_sources; + *sources = cd->wakeup_sources; return IMR_NUM; } -static int gpcv2_wakeup_source_save(void) -{ - struct gpcv2_irqchip_data *cd; - void __iomem *reg; - int i; - - cd = imx_gpcv2_instance; - if (!cd) - return 0; - - for (i = 0; i < IMR_NUM; i++) { - reg = cd->gpc_base + cd->cpu2wakeup + i * 4; - cd->saved_irq_mask[i] = readl_relaxed(reg); - writel_relaxed(cd->wakeup_sources[i], reg); - } - - return 0; -} - -static void gpcv2_wakeup_source_restore(void) -{ - struct gpcv2_irqchip_data *cd; - void __iomem *reg; - int i; - - cd = imx_gpcv2_instance; - if (!cd) - return; - - for (i = 0; i < IMR_NUM; i++) { - reg = cd->gpc_base + cd->cpu2wakeup + i * 4; - writel_relaxed(cd->saved_irq_mask[i], reg); - } -} - -static struct syscore_ops imx_gpcv2_syscore_ops = { - .suspend = gpcv2_wakeup_source_save, - .resume = gpcv2_wakeup_source_restore, -}; - -static int imx_gpcv2_irq_set_wake(struct irq_data *d, unsigned int on) -{ - struct gpcv2_irqchip_data *cd = d->chip_data; - unsigned int idx = d->hwirq / 32; - unsigned long flags; - void __iomem *reg; - u32 mask, val; - - raw_spin_lock_irqsave(&cd->rlock, flags); - reg = cd->gpc_base + cd->cpu2wakeup + idx * 4; - mask = 1 << d->hwirq % 32; - val = cd->wakeup_sources[idx]; - - cd->wakeup_sources[idx] = on ? (val & ~mask) : (val | mask); - raw_spin_unlock_irqrestore(&cd->rlock, flags); - - /* - * Do *not* call into the parent, as the GIC doesn't have any - * wake-up facility... - */ - - return 0; -} - static void imx_gpcv2_irq_unmask(struct irq_data *d) { struct gpcv2_irqchip_data *cd = d->chip_data; @@ -140,11 +85,11 @@ static struct irq_chip gpcv2_irqchip_data_chip = { .irq_eoi = irq_chip_eoi_parent, .irq_mask = imx_gpcv2_irq_mask, .irq_unmask = imx_gpcv2_irq_unmask, - .irq_set_wake = imx_gpcv2_irq_set_wake, .irq_retrigger = irq_chip_retrigger_hierarchy, #ifdef CONFIG_SMP .irq_set_affinity = irq_chip_set_affinity_parent, #endif + .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_MASK_ON_SUSPEND, }; static int imx_gpcv2_domain_xlate(struct irq_domain *domain, @@ -253,7 +198,6 @@ static int __init imx_gpcv2_irqchip_init(struct device_node *node, for (i = 0; i < IMR_NUM; i++) { writel_relaxed(~0, cd->gpc_base + GPC_IMR1_CORE0 + i * 4); writel_relaxed(~0, cd->gpc_base + GPC_IMR1_CORE1 + i * 4); - cd->wakeup_sources[i] = ~0; } /* Let CORE0 as the default CPU to wake up by GPC */ @@ -267,7 +211,6 @@ static int __init imx_gpcv2_irqchip_init(struct device_node *node, writel_relaxed(~0x1, cd->gpc_base + cd->cpu2wakeup); imx_gpcv2_instance = cd; - register_syscore_ops(&imx_gpcv2_syscore_ops); return 0; }