Received: by 10.192.165.148 with SMTP id m20csp4108376imm; Mon, 30 Apr 2018 11:53:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo5Er7t9vQVNzlu0/4/VqyeIXMtYkUd32hXX7SirgUMI6FT0yCeoyxnb6Cgb03XVXafhgzq X-Received: by 2002:a17:902:5602:: with SMTP id h2-v6mr13722344pli.115.1525114434759; Mon, 30 Apr 2018 11:53:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525114434; cv=none; d=google.com; s=arc-20160816; b=uLnlclzgQRuPQlLHpGgsJ8PSgCv3ClphMT6xcTIel/td0v5rOb7lKsCZCqSDh7yQBH 55F/uElJ9KJ1TN4bDPKVVJOmDxVyZxhRI4uSBK5t5GWjbdsHGBwChkN4JZT0UWqC3m1n 9flVNhVEhOZJ/Sst+s94NcAmMTqMq0VtyjBXTZVs7WqqTLLtlcxHam3oHlvO+1nupvZV FdlGn+NHz1LU7TFx7oc0XwqksM0tssms0JkUb7iKxsZ0EllhnG3GNjMVFtZSr2CUkU1z WloQdbb1ncCskPE6OvNg52Wb6NhEimgQnz7rFwsjPBl02XE6Whv+H3w1zDg/3VrG2c/s mWQQ== 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=47+XyXwSm8ZhseBZ7m2G32agWfZVzuqkBXV5CsF289s=; b=yAQsqwbVw1PA8Dcv0hy7xAbfULzOF1dUNDfYuOEw4V7DtTlPh/M0b+5mPJg5jGcm4V /hCtXoSQ7TY0Ggi2Zv3sQSO9LQfEPc7E+541bUOQGZjpOjd3ENXAjyHk5ix6wHllEvWE qhLHs329ruGvIZR+KsZzumoZU5bPjpqN5ugeUviY5a7duq/qLK7nAmbBJZgirE7789OP 80F0MbfQZeYlnH35ePULKRNacHwfnHEIGHq/fJEi0XIwDrtJkPFsOgoXJ9PL/Im+xsuW oo1ibTFRYw53qUV6cHNTlPMrKsCs9o9S7mbris0a0p3dbNkSEhBxGY9OFaEgpa0U//TF HQ+g== 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 i14-v6si2148728pgp.558.2018.04.30.11.53.40; Mon, 30 Apr 2018 11:53:54 -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 S1754752AbeD3SwT (ORCPT + 99 others); Mon, 30 Apr 2018 14:52:19 -0400 Received: from mga12.intel.com ([192.55.52.136]:25647 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753900AbeD3SwS (ORCPT ); Mon, 30 Apr 2018 14:52:18 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Apr 2018 11:52:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,348,1520924400"; d="scan'208";a="38202704" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga006.jf.intel.com with ESMTP; 30 Apr 2018 11:52:18 -0700 Date: Mon, 30 Apr 2018 11:54:56 -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 , Christoph Hellwig , Lu Baolu , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v4 12/22] iommu: introduce device fault report API Message-ID: <20180430115456.54a4b22e@jacob-builder> In-Reply-To: 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> 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, 30 Apr 2018 17:53:52 +0100 Jean-Philippe Brucker wrote: > Hi, > > I noticed a couple issues when testing > > On 16/04/18 22:49, 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; > > Should this be inside the param lock? We probably don't expect > concurrent register/unregister but it seems cleaner agreed, same as corrections below. Thanks! > > [...] > > We should return EINVAL here, if fault_param is NULL. That way users > can call unregister_fault_handler unconditionally in their cleanup > paths > > > + /* we cannot unregister handler if there are pending > > faults */ > > + if (list_empty(¶m->fault_param->faults)) { > > if (!list_empty(...)) > > > + ret = -EBUSY; > > + goto unlock; > > + } > > + > > + list_del(¶m->fault_param->faults); > > faults is the list head, no need for list_del > > > + kfree(param->fault_param); > > + param->fault_param = NULL; > > + put_device(dev); > > + > > +unlock: > > + mutex_unlock(¶m->lock); > > + > > + return 0; > > return ret > > Thanks, > Jean [Jacob Pan]