Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752426AbeAQHpd (ORCPT + 1 other); Wed, 17 Jan 2018 02:45:33 -0500 Received: from regular1.263xmail.com ([211.150.99.131]:60256 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751261AbeAQHpc (ORCPT ); Wed, 17 Jan 2018 02:45:32 -0500 X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: tfiga@chromium.org X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Message-ID: <5A5EFF09.3070604@rock-chips.com> Date: Wed, 17 Jan 2018 15:45:13 +0800 From: JeffyChen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20130126 Thunderbird/19.0 MIME-Version: 1.0 To: Tomasz Figa CC: linux-kernel@vger.kernel.org, Ricky Liang , Robin Murphy , simon xue , Heiko Stuebner , "open list:ARM/Rockchip SoC..." , "list@263.net:IOMMU DRIVERS" , Joerg Roedel , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 01/13] iommu/rockchip: Request irqs in rk_iommu_probe() References: <20180116132540.18939-1-jeffy.chen@rock-chips.com> <20180116132540.18939-2-jeffy.chen@rock-chips.com> <5A5EF672.6040304@rock-chips.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Hi Tomasz, On 01/17/2018 03:16 PM, Tomasz Figa wrote: >>> >> >>> >>This lacks consistency. of_irq_count() is used for counting, but >>> >>platform_get_irq() is used for getting. Either platform_ or of_ API >>> >>should be used for both and I'd lean for platform_, since it's more >>> >>general. >> > >> >hmmm, right, i was thinking of removing num_irq, and do something like: >> >while (nr++) { >> > err = platform_get_irq(dev, nr); >> > if (err == -EPROBE_DEFER) >> > break; >> > if (err < 0) >> > return err; >> > .... >> >} >> > >> >but forgot to do that.. > Was there anything wrong with platform_irq_count() used by existing code? just thought the platform_irq_count might ignore some errors(except for EPROBE_DEFER): int platform_irq_count(struct platform_device *dev) { int ret, nr = 0; while ((ret = platform_get_irq(dev, nr)) >= 0) nr++; if (ret == -EPROBE_DEFER) return ret; return nr; } but guess that would not matter.. > >> > >>> >> >>>> >>>+ if (irq < 0) { >>>> >>>+ dev_err(dev, "Failed to get IRQ, %d\n", irq); >>>> >>> return -ENXIO; >>>> >>> } >>>> >>>+ err = devm_request_irq(iommu->dev, irq, rk_iommu_irq, >>>> >>>+ IRQF_SHARED, dev_name(dev), >>>> >>>iommu); >>>> >>>+ if (err) >>>> >>>+ return err; >>>> >>> } >>> >> >>> >> >>> >>Looks like there is some more initialization below. Is the driver okay >>> >>with the IRQ being potentially fired right here? (Shared IRQ handlers >>> >>might be run at request_irq() time for testing.) >>> >> >> >right, forget about that. maybe we can check iommu->domain not NULL in >> >rk_iommu_irq() > Maybe we could just move IRQ requesting to the end of probe? > ok, that should work too. and maybe we should also check power status in the irq handler? if it get fired after powered off... > Best regards, > Tomasz > > >