Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752922AbcKOLWt (ORCPT ); Tue, 15 Nov 2016 06:22:49 -0500 Received: from mail-bn3nam01on0068.outbound.protection.outlook.com ([104.47.33.68]:11025 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751762AbcKOLWq (ORCPT ); Tue, 15 Nov 2016 06:22:46 -0500 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; ellerman.id.au; dkim=none (message not signed) header.d=none;ellerman.id.au; dmarc=bestguesspass action=none header.from=xilinx.com; X-IncomingTopHeaderMarker: OriginalChecksum:;UpperCasedChecksum:;SizeAsReceived:1774;Count:18 Subject: Re: [Patch V6 2/6] irqchip: xilinx: Clean up irqdomain argument and read/write References: <1477916207-25157-1-git-send-email-Zubair.Kakakhel@imgtec.com> <1477916207-25157-3-git-send-email-Zubair.Kakakhel@imgtec.com> <30e73e32-3144-3222-c758-dd8affd9b276@arm.com> To: Marc Zyngier , Zubair Lutfullah Kakakhel , Thomas Gleixner CC: , , , , From: Michal Simek Message-ID: <9f06a324-a59a-378d-99ae-8a4c2549331c@xilinx.com> Date: Tue, 15 Nov 2016 12:06:45 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <30e73e32-3144-3222-c758-dd8affd9b276@arm.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-22700.004 X-TM-AS-User-Approved-Sender: Yes;Yes X-IncomingHeaderCount: 18 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.100;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(7916002)(2980300002)(438002)(377454003)(199003)(51914003)(189002)(24454002)(81156014)(65806001)(81166006)(9786002)(87936001)(31686004)(36756003)(2906002)(8936002)(8676002)(83506001)(86362001)(50466002)(356003)(47776003)(7846002)(305945005)(5660300001)(626004)(65826007)(230700001)(2950100002)(6666003)(31696002)(4001350100001)(65956001)(5001770100001)(33646002)(229853002)(54356999)(76176999)(64126003)(50986999)(93886004)(36386004)(189998001)(106466001)(23746002)(4326007)(77096005)(92566002)(63266004)(107986001)(5001870100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN1PR02MB006;H:xsj-pvapsmtpgw02;FPR:;SPF:Pass;PTR:unknown-60-100.xilinx.com,xapps1.xilinx.com;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;CY1NAM02FT036;1:PX97V4lRIQR/A6kHKb9pUlDGn0IwajBelTcilT66iLeBzFS1TMTBkPQi8kxA8Qvuv3H7ktQGNv86+qVYdDZXYnxQ6+UDToJ6nV4nt4YYWSKUOgo5wngFkFR+vQsAdT4NohWCrH9aMPTbHH1dNddO6AU4phODFQ1Zb47BtCTIqYsZhPmdFQT6pZ6iws/AJCA6J8x6RPQN603noAn1JfD7IAtH29HUR0h69JO9iwy3E8ElP0TTQPREC8y3jH1LGDFyX9lqZYoIyjUlvoIfCUfLZETXTLBU8FnufEzc4RVYK88j8YK4oBXVUME/oaEhAeflsxMqFE4PywW9Mn6H8u7qwe5Ey8n0+l8b8MTQ0qeL0PCZpyNJAuaoqxcANNeLt5VcfyFk+HvXk1KZuAfcUX98gC4JIcwdWznd+HcOOx8WUW7JChllfKyel+b8KWT4ThzAGvhnKe9mUWF2cwaIGhTJQPOf70osw5k2zrufZudQBwwNyzzsWVEIIOv8QChGeQ63HbUslb2rwhL/xFfOokOqdkEkIGLgnGFAO+yNfSRVCnlSAhPneHahTIje1o1NM4EaP8GQV1ZhlQhjWX1sNx4N6RRw91yLnsvWhVk7NVxMT7Pfeoi31htRYRl+Go3OfQ+i X-Microsoft-Exchange-Diagnostics: 1;BN1PR02MB006;2:PXzl/t5nJWsZA7cn6Dg1OzkIVX2za00STPiz+bsQlbRp7wt9t+lo0tgTKY962psQYUhjy4aMmyY+HVS7FAo83on/m8GMHTDSmSrRtmw8kSWDsndu0ake5fZaIC/N+pos2ehpWnReykNI0VQidIyZIvSKrdZTEA/6ZBR6mSyWSMQ=;3:CDBs9YYFAMGF03GnW+UG6+FNclXtL8Nm3pQvBzHgybywUO15ejVnabpcFtOcKdielTSCQhLVsLbZ0H8iqb+8DdP+Z7jDYR0ST+Jt/vbMnNlNhkAPhqGtRJsIOccQpRwNuTXlOQUwDyOtS3hh/V4dV1+uDCLOqTI2zmz4Y+IAT8I65ex08z+APuLxkIf33+Tdh0VGuFYpxC+bMY5A2QLJzA0j6z4Cs+GcmnIGjgC+fe2iUmXjoCrD7mNPY1JSMCia8EytOiJ8u3C+m2NRGTbliqNdc0KLOcPKeXY5CfNCNk0=;25:bdwvKzv5KcV69l/RKCTyxXihYtFa/hR3AYu8pwzsB7JM3mOfoVfJoeUy2/GwAk4UFo6JZSC0BdCXW9c5y85wFPfUbdStEbD0kbiUVJpO1KICb1mwEdikJWnZBSSlCdOlKKyGe9xL+EBQEBntpk0J0RS6hvNzdBBVr1qtXAhYDtGDsjvhMNwuZDA14NGeed0HM6RYUmZbYFHi+zLnZj/J8PtLQvrIE5jz6hlK/7n/DyP4M6obh7eUKQ+hbGvC4ORCR4R0RpKMbeZVIpB+yK2ygPnrrENV72PgscjgUr/KTO6QlwakvIfBCCXZTztUyzCVpZQjGZMBkJn6feLSehG5zYA2tiPWKuedZ0A9BDRp7rwgwkpNcxJ3q5Sto9yW9sxB8VLhgt2XcviE4dS6LXxK4P9WsY+Uh/H3aHgBoRfpDEDhFPSWEuQSxEzc6S8iQYk0 X-MS-Office365-Filtering-Correlation-Id: fa915867-0124-42e9-2572-08d40d4786d9 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(8251501002);SRVR:BN1PR02MB006; X-Microsoft-Exchange-Diagnostics: 1;BN1PR02MB006;31:5yrKpffZnfnZCpuFzXkYXr/16f1w7tPiP/M/668/v9DS1N6RG7hAju2UptZx/UsRNFSMB7sfUBJUgSDOxuZOmg0qV+KRpyUs2B/giqzswGbekqTfPRHIX1ZTLhON6ES9TCB9d4I7wMxpb8Vaqax9Q+W3o+a5GviuOm3Un2SGPVcCViWxLURgGzRQrHOjQj2HgVhP2Pb8c8zaq54dzwzrul+Lkbakjjis6wEwEsir/fIN39gf6aFYqiJ/3V5cEdQ2;20:J1m0WsZmez8MyKQg6D/TfMX4W4hDMEM/COpHCZCgRe/ycAQ9I4iuAUVMLw0ocOn0jxOxRuzGNWJkc9Lg6BAg348jlh4ZqTfvWAswaPktYmuQpkBgWwLrRwG0UgvQVoV+RQFstNc3YESKNtIiHaeHjlt76iRljbCk5Tgl7oQyPZoMe1vVc+yvgM2TPy7dslm/O3aS69aZcTmN5meMIUPgDxK0o0ee+jOlSeDUjGF3D8DczMhI0c2GBdlx7WImYdOu9x+75AiW9wqLHJAdSrCxw9LAu8YnrVBm3BAbVJxiBV7Og7a+C+V6oBWirPDeHOpll39cxaEKGLCugTqYIhULsomA+uiCvc6EZNGFAjA8H7L8QMzSxaQnM0SkjBTnfhHYZfKIcLRIO9z78HFpX59CJLlPiNCUoDn8ZSJH9EeB61sqlg7UOo+1mPTvO15s+UDOiZFd7/GLhg1QPF3i9EXixicN1EPuykMCVGr1BN+JgpJbBfsN0Rcx13A8Q2ps24TC X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(21532816269658); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6060326)(601004)(2401047)(5005006)(8121501046)(13017025)(13024025)(13018025)(13023025)(13015025)(10201501046)(3002001)(6055026)(6061324);SRVR:BN1PR02MB006;BCL:0;PCL:0;RULEID:;SRVR:BN1PR02MB006; X-Microsoft-Exchange-Diagnostics: 1;BN1PR02MB006;4:QpJmWx1U55IDeTKxWDvexggSKtVjMpcdEyZ5TYjH6S4ZwVnuoGaYedAQjsV7/d+3lQwjHJUQtfzv52eCCNLADAa9P/5P7A+fAb9VlWjw7IzRdkNAP9ASIf5065yspdcjGU9FHRR5RpX/8ndPcmkczuaod4B6seKE6L+6+OkC3Eb5534/KmT1KKhUIUPuZNTLtT4XLouhTuMJqtvOSiFVB6DgzpiBuCbonVEkzNc5uS0Hoo25xwUXrzmEynFRkyX59LI6/lKGgaF9DgSPZ/WqnEz2JNoQlefAo8Snx5kzNqqmjoODK28eEov3xeiE0Q+uSoPdFj7qyQ80Bt7SMeVr3vy5gi+J4tWb7EdKVYKtOBzMo0CqFzmS9siQlHEH5kv1skOUdoaE7caZ3YrDTgn9Ndjxkr51t1MQ4dw6VeDXtvQJeY5HEjn8SOFnL5h5iJqddotXxmf8nmKjdOqOmZPtQyQKD0Usx07dez/xNskOT6S4AfxNGV2t/x9UW8yA+zD8V5pWnWZAM76fKB2rJph1r7HTctwav35DjtFa3hEzIY0L2FaknkBbpeKNaoOlSODcld7of7+hPJyN5Zel7jOspQ== X-Forefront-PRVS: 012792EC17 X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;BN1PR02MB006;23:hDMwKm/ihhlbjvuUJMoy2qNgzCO9EMJerUB20L?= =?Windows-1252?Q?pItt+pE9yoeFfRGt8IFyI11wwKTXN9KFT1iUDAQNyArQTqSZSnacyzal?= =?Windows-1252?Q?hdZk0Ydy91lUysfNsf9OhumZIpElnIJCKK/UeMCKCs2dQfNkOFeuZOrw?= =?Windows-1252?Q?tOuNQBaT8np+SFWMU36YyHyfjh6jJ0ls7uv5P5u9zmGyinsbqietmliQ?= =?Windows-1252?Q?4aWKURi5u3jxGoC/O43eMBUTJk8ivE2wsS4g/QVz+6+Sy15wz/VryCA0?= =?Windows-1252?Q?tlnKp0zxiLyQW1Tmfjm4dHUf3uplVU9ww+pYnrOaM/SbgfekKvYyxQps?= =?Windows-1252?Q?SuxT0vKHdqf1dJEm4qQgEvZgtrBbLWAbP769GjwvxxVOa2zCiuM6CfTC?= =?Windows-1252?Q?x7hixJHwEPvSOw8+uoNF8aivEqY/krXcyfUDkux6VzSFMobpDmUDlXkR?= =?Windows-1252?Q?XNeruaLPoHjD/cwIrgil0nlvVukVbAxcP1mUbdQUkEUSAAqR1Hb1j9vp?= =?Windows-1252?Q?cq/N1DN62/G8N3nS6uCjfyq+imTabSFHyRsiL0K8w4zEyd7QVhvV3FEH?= =?Windows-1252?Q?Pw6yfn4vvERK31fw5AWOOs8aXTKe29nNPUQXpHHM0BYyX9ZUTCXa4gaY?= =?Windows-1252?Q?GGPz33ZYZl0HaBgfovXS5zJg5CNFGj8SYFJFXJyP1vg7ANlM48TqQBTt?= =?Windows-1252?Q?eUPa8qsb1XzHKB8o0msHj7/76KN6Q/RKN7zTrwOXanWWAuBhEOnNK05M?= =?Windows-1252?Q?ccPU4hZtDImvk0id0L79hOSrD/ZtIZAjZKuvOKrhsKfW0PrtLCaWg7ow?= =?Windows-1252?Q?DRPQAtdBRKFwlZxhCQoakFDY6DeI12lYwc2NB1vos+f17hqm4ODfJ/BM?= =?Windows-1252?Q?Y5Bjv9AhTtsUPW4pS+1zmGwGeAtoBFC6xFV3ikoro8wgzGUW9JEucGLv?= =?Windows-1252?Q?Vpy6AB13BJNdmoV8mcglmrLGN1fD6Gq8mdYlYqjBGGLnRKpK8ndQWVkm?= =?Windows-1252?Q?8e+TiiZDKz9CDlHc74E9CcBgOXMbHHNVUdAcEZB7z9S8Rv06RO2CANDa?= =?Windows-1252?Q?9fpDdn1dZKU+gbvzf0viaIqxcyzQHmqgURTajEVOxx8F4ztd3SdxNFAx?= =?Windows-1252?Q?pmUNe/Z4h3dXyd62oslLoLPsCVH/VxhqZJGb52Ykcfy+ch8rjpYJih7k?= =?Windows-1252?Q?tSkcdxh5knLBjxKLa8WkdYvuz8HwSieO4PLQ9WYaegu0f/abu4/PNbut?= =?Windows-1252?Q?5wwb4pwo980UTz268RI6pu93xF9k+cVIBwu9mN/evqJi4cvkyDO1KSH+?= =?Windows-1252?Q?tihTxCmZlSJA4PQsHcMCuXLY6tCKNG3N8eRG46DFfAZgoBZO44FWFHNd?= =?Windows-1252?Q?kiOQ28EF/v?= X-Microsoft-Exchange-Diagnostics: 1;BN1PR02MB006;6:nLaW3+WczOg23OT2Bmzz/heVEyrKNTdfUFkHWHbO36cJl0X6vBQyKm9D37AKyP3xmqm4tQgt2fTRor6URCjlTnhwTy8c+cVsoD5erxVDc33UlJsixU9Ys7jK5QyP1ify9Q+FJImwPpgg8h1Bpz96He+Hs9ytU0kzT9fmzSd4d2m+Rjv+mC+K2PeCEl4ow1IfFoH93KhsDSwLDvIVpmpYg0iq9A4KZjOcSVROsv8dH7Z5XO9sHa4NkQm5R2cpWAS5C9AyD804wjsLTuLq9XtNcVK4uD7DjtBViwRdLX7GgKrXf/v7fb9gSqAk4NXhfh5LySVlgLjn2KnlFmU1qMsIZi4oMNd6DHbYMDSncpvelbMsl4SjVBNCzGRWm3DHFnxn;5:HHiGAE9UZ/tZxLsfijd8oCnES/KqLQoK3g4bll2XI9zmiuEkQf4mv+1RAFpB2n20FykSkCH5WMFDIa/Mj4pEhkg1S8uzfbechwK/uajDndJ5kq1kUydupDEfB76qVnmfFgekpPiibKgApPrEcVuDWw==;24:8uxbBXjz1N2QyxfTA4nis5LMaUz99m6/8pcQc2nlJGKhp1thhZHleClzvPvx9AJt99MqPLWY4rBCFOVRwNnk1JuVj4Lsfk19RXqGv6VTTho= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN1PR02MB006;7:VjPWyQlRuJxanY9lJcaL6pNygOyysipq3puIwFIjHyDbT+pgmfBuJcZMf1DpxlKswuO+sps7GLdbivr50gXTw7fED5T41i4938HQMuQaq5VsggVjWo1H0n+p4ljC5yykRcXTyNORoK9Y8htj2UAFOR/ktY15RMswb/fuV+YZtRlewO3vgpVyn6nbhba4mFTrcAs5S218PKXxOcjkgxkRfuwypSNboHwVq8mWH03x77KRTUr4O4AWfptX/jfTG7EyK87cNhOgkAwcYrFzwDuATrzbjd9tr6fDPjCBDtJQSxX9E9BP4Ylt8cfgb25eyixvznud58HaoxXrgFCICXHjRs+afRQlFkz8SqEGnOXucJg= X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2016 11:07:01.7299 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.100];Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR02MB006 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4906 Lines: 137 On 9.11.2016 16:53, Marc Zyngier wrote: > On 01/11/16 11:05, Zubair Lutfullah Kakakhel wrote: >> Hi, >> >> Thanks for the review. >> >> On 10/31/2016 07:51 PM, Thomas Gleixner wrote: >>> On Mon, 31 Oct 2016, Zubair Lutfullah Kakakhel wrote: >>>> The drivers read/write function handling is a bit quirky. >>> >>> Can you please explain in more detail what's quirky and why it should be >>> done differently, >>> >>>> And the irqmask is passed directly to the handler. >>> >>> I can't make any sense out of that sentence. Which handler? If you talk >>> about the write function, then I don't see a change. So what are you >>> talking about? >> >> Thanks. I'll add more detail in v7 if this patch survives. >> >>> >>>> Add a new irqchip struct to pass to the handler and >>>> cleanup read/write handling. >>> >>> I still don't see what it cleans up. You move the write function pointer >>> into a data structure, which is exposed by another pointer. So you create >>> two levels of indirection in the hotpath. The function prototype is still >>> the same. So all this does is making things slower unless I'm missing >>> something. >> >> I wrote this patch/cleanup based on a review of driver by Marc when I moved the >> driver from arch/microblaze to drivers/irqchip >> >> "Marc Zyngier >> >> ... >> >> > arch/microblaze/kernel/intc.c | 196 ---------------------------------------- >> > drivers/irqchip/irq-axi-intc.c | 196 ++++++++++++++++++++++++++++++++++++++++ >> >> ... >> >> > + /* Yeah, okay, casting the intr_mask to a void* is butt-ugly, but I'm >> > + * lazy and Michal can clean it up to something nicer when he tests >> > + * and commits this patch. ~~gcl */ >> > + root_domain = irq_domain_add_linear(intc, nr_irq, &xintc_irq_domain_ops, >> > + (void *)intr_mask); >> >> Since you're now reworking this driver, how about addressing this >> ugliness? You could store the intr_mask together with intc_baseaddr, >> and the read/write functions in a global structure, and pass a >> pointer to it? That would make the code a bit nicer... >> " >> >> https://patchwork.kernel.org/patch/9287933/ >> >>> >>>> -static unsigned int (*read_fn)(void __iomem *); >>>> -static void (*write_fn)(u32, void __iomem *); >>>> +struct xintc_irq_chip { >>>> + void __iomem *base; >>>> + struct irq_domain *domain; >>>> + struct irq_chip chip; >>> >>> The tabs between struct and the structure name are bogus. >>> >>>> + u32 intr_mask; >>>> + unsigned int (*read)(void __iomem *iomem); >>>> + void (*write)(u32 data, void __iomem *iomem); >>> >>> Please structure that like a table: >>> >>> void __iomem *base; >>> struct irq_domain *domain; >>> struct irq_chip chip; >>> u32 intr_mask; >>> unsigned int (*read)(void __iomem *iomem); >>> void (*write)(u32 data, void __iomem *iomem); >>> >>> Can you see how that makes parsing the struct simpler, because the data >>> types are clearly to identify? >> >> That does make it look much better. >> >>> >>>> +static struct xintc_irq_chip *xintc_irqc; >>>> >>>> static void intc_write32(u32 val, void __iomem *addr) >>>> { >>>> @@ -54,6 +60,18 @@ static unsigned int intc_read32_be(void __iomem *addr) >>>> return ioread32be(addr); >>>> } >>>> >>>> +static inline unsigned int xintc_read(struct xintc_irq_chip *xintc_irqc, >>>> + int reg) >>>> +{ >>>> + return xintc_irqc->read(xintc_irqc->base + reg); >>>> +} >>>> + >>>> +static inline void xintc_write(struct xintc_irq_chip *xintc_irqc, >>>> + int reg, u32 data) >>>> +{ >>>> + xintc_irqc->write(data, xintc_irqc->base + reg); >>>> +} >>>> + >>>> static void intc_enable_or_unmask(struct irq_data *d) >>>> { >>>> unsigned long mask = 1 << d->hwirq; >>>> @@ -65,21 +83,21 @@ static void intc_enable_or_unmask(struct irq_data *d) >>>> * acks the irq before calling the interrupt handler >>>> */ >>>> if (irqd_is_level_type(d)) >>>> - write_fn(mask, intc_baseaddr + IAR); >>>> + xintc_write(xintc_irqc, IAR, mask); >>> >>> So this whole thing makes only sense, when you want to support multiple >>> instances of that chip and then you need to store the xintc_irqc pointer as >>> irqchip data and retrieve it from there. Unless you do that, this "cleanup" >>> is just churn for nothing with the effect of making things less efficient. >>> >> >> Indeed the driver doesn't support multiple instances of the Xilinx Interrupt controller. >> I don't have a use-case or the hardware for that. >> >> So what would be the recommended course of action? > > If you really don't want/need to support multi-instance, then this is > indeed overkill. You're then better off having a simple static key that > deals with the endianess of the peripheral, and have a global structure > that contains the relevant data: By design this is PL IP and multi-instance support should be there. You are using it with MIPS but you can connect more INTC together. Thanks, Michal