Received: by 10.192.165.148 with SMTP id m20csp4975076imm; Tue, 24 Apr 2018 11:29:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/aDOdQukaZ6HHU8dIAfYytspX5gvmfGcqZPGvdlGoLyuozdEzztxE2tZz/rZVUl9i8tYw6 X-Received: by 10.98.35.11 with SMTP id j11mr15433388pfj.177.1524594540098; Tue, 24 Apr 2018 11:29:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524594540; cv=none; d=google.com; s=arc-20160816; b=F1LgzmCmpEXfvCh5baH+93ZLOX2+EmkGf+RJT1hvWTJpBhH+ouZ35zDzvq3KeuKRAN NEg8PypJsqEncvG7ubxv1AZQL/ZXqXSzz48AUUZRNm3KdjXR92ImvVj5JZMGDOP/JKjk EZyl70nOA+cdun3UYMuVA2feFeiaaj54Wyo8ED1+zal6rr/woQO6eV111YEoDoMpaLzF i41KZxTRueJAWuIfueuQWxe6za0AnWO1gddR7g/PCzKsIWcAIynRnsanIsrwL1AY/O2F nH9U0YZ+CF8T+gE467mY4TwmqXodjfAh0dx6WdeduZGP7LBnpKVnFRXXMhvv7rlaXOR/ 32Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=ugnFV3sR+V7ooTg//zxXK0RNfS58YF011G31uihA5pE=; b=aBGD3MH861QfddKibZb58dtc+xR1anXSPVIZkTfVmMVUasr2N+wwGaoOmb0QVWJZzW M/Q/riJwZy/G336uAdhbw5qrcj/kWa3Utp6oyhi+kRDrJfFBblgfycNtUHTafvwUwh8U rRV9rhmCmOGfYSB9XV8DoDMf/Mbtk+01teztv1ICDYuN0TmXfeQ//KdJs2VceqZhGTxj VhwHb9leqkL27T7hKIr0dB88Wc3YobkVXMQztZK1XKQPpvgkKyRv4f5XjKKWEan5ZL91 M/IBVmCvGrkK8MRkw1g8kfA+JtSegS0gCcyVJrFdbNWwrVBrGBFrFnw4n7amchOlIBX8 G9xw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10si982371pgq.249.2018.04.24.11.28.45; Tue, 24 Apr 2018 11:29:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753154AbeDXS1P (ORCPT + 99 others); Tue, 24 Apr 2018 14:27:15 -0400 Received: from mga02.intel.com ([134.134.136.20]:3799 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753125AbeDXS1J (ORCPT ); Tue, 24 Apr 2018 14:27:09 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Apr 2018 11:27:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,324,1520924400"; d="scan'208";a="194053115" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga004.jf.intel.com with ESMTP; 24 Apr 2018 11:27:08 -0700 Date: Tue, 24 Apr 2018 11:29:43 -0700 From: Jacob Pan To: Jean-Philippe Brucker Cc: "iommu@lists.linux-foundation.org" , LKML , Joerg Roedel , David Woodhouse , Greg Kroah-Hartman , Alex Williamson , Rafael Wysocki , "Liu, Yi L" , "Tian, Kevin" , Raj Ashok , Jean Delvare , Christoph Hellwig , Lu Baolu , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v4 12/22] iommu: introduce device fault report API Message-ID: <20180424112943.79af1c3f@jacob-builder> In-Reply-To: <20180423113013.GB38106@ostrya.localdomain> References: <1523915351-54415-1-git-send-email-jacob.jun.pan@linux.intel.com> <1523915351-54415-13-git-send-email-jacob.jun.pan@linux.intel.com> <20180423113013.GB38106@ostrya.localdomain> Organization: OTC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 23 Apr 2018 12:30:13 +0100 Jean-Philippe Brucker wrote: > On Mon, Apr 16, 2018 at 10:49:01PM +0100, Jacob Pan wrote: > [...] > > +int iommu_register_device_fault_handler(struct device *dev, > > + iommu_dev_fault_handler_t > > handler, > > + void *data) > > +{ > > + struct iommu_param *param = dev->iommu_param; > > + > > + /* > > + * Device iommu_param should have been allocated when > > device is > > + * added to its iommu_group. > > + */ > > + if (!param) > > + return -EINVAL; > > + > > + /* Only allow one fault handler registered for each device > > */ > > + if (param->fault_param) > > + return -EBUSY; > > + > > + mutex_lock(¶m->lock); > > + get_device(dev); > > + param->fault_param = > > + kzalloc(sizeof(struct iommu_fault_param), > > GFP_ATOMIC); > > This can be GFP_KERNEL > yes, will change. > [...] > > +int iommu_report_device_fault(struct device *dev, struct > > iommu_fault_event *evt) +{ > > + int ret = 0; > > + struct iommu_fault_event *evt_pending; > > + struct iommu_fault_param *fparam; > > + > > + /* iommu_param is allocated when device is added to group > > */ > > + if (!dev->iommu_param | !evt) > > + return -EINVAL; > > + /* we only report device fault if there is a handler > > registered */ > > + mutex_lock(&dev->iommu_param->lock); > > + if (!dev->iommu_param->fault_param || > > + !dev->iommu_param->fault_param->handler) { > > + ret = -EINVAL; > > + goto done_unlock; > > + } > > + fparam = dev->iommu_param->fault_param; > > + if (evt->type == IOMMU_FAULT_PAGE_REQ && evt->last_req) { > > + evt_pending = kzalloc(sizeof(*evt_pending), > > GFP_ATOMIC); > > We're expecting caller to be a thread at the moment, so this could be > GFP_KERNEL too. You could also use kmemdup to remove the memcpy below > good idea. will do. > [...] > > +static inline int iommu_register_device_fault_handler(struct > > device *dev, > > + > > iommu_dev_fault_handler_t handler, > > + void *data) > > +{ > > + return 0; > > Should return -ENODEV > right. thanks. > Thanks, > Jean [Jacob Pan]