From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754045AbdKMRUq (ORCPT ); Mon, 13 Nov 2017 12:20:46 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:48860 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753949AbdKMRUp (ORCPT ); Mon, 13 Nov 2017 12:20:45 -0500 Subject: Re: [PATCH v2 08/16] iommu: introduce device fault data To: Jacob Pan Cc: "Liu, Yi L" , "iommu@lists.linux-foundation.org" , LKML , Joerg Roedel , David Woodhouse , Greg Kroah-Hartman , "Wysocki, Rafael J" , "Lan, Tianyu" , "Tian, Kevin" , "Raj, Ashok" , Alex Williamson References: <1507244624-39189-1-git-send-email-jacob.jun.pan@linux.intel.com> <1507244624-39189-9-git-send-email-jacob.jun.pan@linux.intel.com> <439401c0-a9ff-a69a-dc10-12d72f7abbab@arm.com> <09d451dc-c0e9-1fa2-8f85-45a9b1185d48@arm.com> <20171109113629.6a9251a4@jacob-builder> <0ed3e52b-2ca7-e378-817b-34b517a392da@arm.com> <20171110141803.78eca80b@jacob-builder> <20171113085726.237b7a07@jacob-builder> From: Jean-Philippe Brucker Message-ID: <0f500cee-77ea-4dc7-0ee2-3a0fe06e4b1b@arm.com> Date: Mon, 13 Nov 2017 17:23:14 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171113085726.237b7a07@jacob-builder> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/11/17 16:57, Jacob Pan wrote: > On Mon, 13 Nov 2017 13:06:24 +0000 > Jean-Philippe Brucker wrote: > >> On 10/11/17 22:18, Jacob Pan wrote: >>> On Fri, 10 Nov 2017 13:54:59 +0000 >>> Jean-Philippe Brucker wrote: >>> >>>> On 09/11/17 19:36, Jacob Pan wrote: >>>>> On Tue, 7 Nov 2017 11:38:50 +0000 >>>>> Jean-Philippe Brucker wrote: >>>>> >>>>>> I think the IOMMU should pass the struct device associated to the >>>>>> BDF to the fault handler. The fault handler can then deduce the >>>>>> BDF from struct device if it needs to. This also allows to >>>>>> support faults from non-PCI devices, where the BDF or deviceID >>>>>> is specific to the IOMMU and doesn't mean anything to the device >>>>>> driver. >>>>> Passing struct device is only useful if we use shared fault >>>>> notification method, as I did in V1 patch with group level or >>>>> current domain level. >>>>> >>>>> But the patch proposed here is a per device callback, there is no >>>>> need for passing struct device since it is implied. >>>> >>>> Sorry I had lost sight of the original patch in this thread. I >>>> think the callback is fine as it is, in your patch: >>>> >>>> typedef int (*iommu_dev_fault_handler_t)(struct device *, struct >>>> iommu_fault_event *); >>>> >>> I should have removed struct device here also. thanks for pointing >>> it out. >> >> Why remove it? The device driver will use a single C function as fault >> handler for multiple devices, so it needs struct device argument to >> understand the context. >> > I meant to replace struct device * with just a void *, driver can > register fault callback with instance of their private data, this could > be a container struct of struct device. > e.g. > int iommu_register_device_fault_handler(struct device *dev, > iommu_dev_fault_handler_t handler, void > *data); > > typedef int (*iommu_dev_fault_handler_t)(struct iommu_fault_event *, void *); Ah I see. Yes that should work Thanks, Jean