From patchwork Mon Mar 7 15:30:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 8520441 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 CF294C0553 for ; Mon, 7 Mar 2016 15:32:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D72FD2025A for ; Mon, 7 Mar 2016 15:32:11 +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 F3E70201D3 for ; Mon, 7 Mar 2016 15:32:10 +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 1acx7D-0001M6-4S; Mon, 07 Mar 2016 15:30:35 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1acx79-0001Fc-3w for linux-arm-kernel@lists.infradead.org; Mon, 07 Mar 2016 15:30:31 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id EECBB60897; Mon, 7 Mar 2016 15:30:09 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D77896060D; Mon, 7 Mar 2016 15:30:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from [10.228.68.98] (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id D662F60349; Mon, 7 Mar 2016 15:30:07 +0000 (UTC) Subject: Re: [PATCH V14 8/9] vfio, platform: add support for ACPI while detecting the reset driver To: Eric Auger , dmaengine@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, timur@codeaurora.org, devicetree@vger.kernel.org, cov@codeaurora.org, vinod.koul@intel.com, jcm@redhat.com References: <1454646882-24369-1-git-send-email-okaya@codeaurora.org> <1454646882-24369-9-git-send-email-okaya@codeaurora.org> <56D08843.5020306@linaro.org> <56D7323B.4040100@codeaurora.org> <56D8C539.9000203@linaro.org> <56D91B0E.1080203@codeaurora.org> <56DCFEE0.6080101@linaro.org> From: Sinan Kaya Message-ID: <56DD9E7E.6000406@codeaurora.org> Date: Mon, 7 Mar 2016 10:30:06 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56DCFEE0.6080101@linaro.org> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160307_073031_289769_71837AB5 X-CRM114-Status: GOOD ( 19.85 ) 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: vikrams@codeaurora.org, arnd@arndb.de, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, shankerd@codeaurora.org, agross@codeaurora.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-Virus-Scanned: ClamAV using ClamSMTP On 3/6/2016 11:09 PM, Eric Auger wrote: >> #define module_vfio_reset_handler(compat, acpihid, reset) \ >> > MODULE_ALIAS("vfio-reset:" acpihid? acpihid: compat); \ >> > >> > This way, we'll create an alias with one of the provided strings. > What if you want to use vfio platform driver for HiDMA in dt mode? the > HiDma reset module advertises both acpihid and dt compat support but an > alias module will be created only for acpihid. Then I think we will not > be able to load the reset module in dt mode with existing code. > Right, it won't work. Now that we know what MODULE_ALIAS does, there is no harm in doing this. I think we should do this. #define module_vfio_reset_handler(compat, acpihid, reset) \ MODULE_ALIAS("vfio-reset:" compat); \ MODULE_ALIAS("vfio-reset:" acpihid); \ If we prefer ACPI over DT, there is no guarantee that somebody can boot DT kernel with ACPI kernel compilation option enabled. If one of these are null, then the module alias will be "vfio-reset:" Of course to make things prettier, we could use "NOT SUPPORTED" as a string instead of NULL. then, the module alias will be vfio-reset: NOT SUPPORTED". We could go one step further, and do. #define module_vfio_reset_handler(compat, acpihid, reset) \ MODULE_ALIAS("vfio-reset: dt: " compat); \ MODULE_ALIAS("vfio-reset: acpi: " acpihid); \ and change the code below for this too. > This could work however with some rework in vfio_platform_common.c. In > vfio_platform_get_reset we should try to load the module using the > acpihid if the module load using compat alias fails. In the look-up > table we can find the acpihid corresponding to the dt compat. I was planning to submit this for the next review. Still, I don't want to assume that acpihid is the only working option. Somebody can boot DT kernel. Let me know what you think. diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index 42d7545..ba585ad 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -58,16 +58,30 @@ static vfio_platform_reset_fn_t vfio_platform_lookup_reset(const char *compat, return reset_fn; } -static void vfio_platform_get_reset(struct vfio_platform_device *vdev) +static int vfio_platform_get_reset(struct vfio_platform_device *vdev) { + int rc; + vdev->reset = vfio_platform_lookup_reset(vdev->compat, vdev->acpihid, &vdev->reset_module); - if (!vdev->reset) { - request_module("vfio-reset:%s", vdev->compat); - vdev->reset = vfio_platform_lookup_reset(vdev->compat, - vdev->acpihid, - &vdev->reset_module); - } + if (vdev->reset) + return 0; + + if (vdev->acpihid) + rc = request_module("vfio-reset:%s", vdev->acpihid); + + if (rc && vdev->compat) + rc = request_module("vfio-reset:%s", vdev->compat); + + if (rc) + return rc; + + vdev->reset = vfio_platform_lookup_reset(vdev->compat, vdev->acpihid, + &vdev->reset_module); + if (vdev->reset) + return 0; + + return -ENODEV; } static void vfio_platform_put_reset(struct vfio_platform_device *vdev) @@ -620,7 +634,11 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev, return ret; } - vfio_platform_get_reset(vdev); + ret = vfio_platform_get_reset(vdev); + if (ret) { + iommu_group_put(group); + return ret; + } mutex_init(&vdev->igate);