Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5070044yba; Tue, 30 Apr 2019 08:40:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+dQOscdEzFvDq79V/UhQagM9I/x9P77b1w6YND0XQUeJjlP+AuloZL7U1gSWoYb6Y7Dyh X-Received: by 2002:a17:902:3c5:: with SMTP id d63mr20034980pld.328.1556638814005; Tue, 30 Apr 2019 08:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556638813; cv=none; d=google.com; s=arc-20160816; b=t7YTKKAR3PLlTJEyTkFwL7sAAAPwN038tjCZVxKAHM6bxDICAN+sjP4jOk1VkRp/pH vZVWvJLtS0CkrLP7IMezKOYdZmEPlBRTAsP8iIbZxaVfdtLqVgwi9lZrhnxiFQgE1v4J z5pbNNHM+hOXTuPTvvKT3ipFL7sF/ruNj/KZAS3vHH2W39+cUrhVFgnDUzgy6CwvczGz U0wjtvIRxle05IPLQy7sMynDvv0ioWHowy8JwLm0zidaZmZGQDR+bLl77w4xw/DoHJuS 54BNhLKuJvmTFbefyXdnitjZsK2IS2q4XEgjB3oEDoqkmPh7kESaMlFrKDH0NHHXvWsE 9//g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=jcI2Gl6bhWDqctKnjLJVZyTtaENfxKpEtCqUxb8qIgk=; b=mC3AGorVbwF7kpZbTrTBliDtds6m2Bm8KTFtGGEgui4KmyyBKA8YXOV/uOhjRyYAXm CArEKr+oQjJqYZGdBJTNJPjhH1Gkf2t7d6W7RC6o3vsmw19G0yUW9HjSuyuJh2H0IClo 3eXvs8khu5D+HD4WqiSu8vGuj/3zO6/RT+pD6f07tcyk+kkkBNLPcO2HyERf12czR13Q /kkeSoIab7TxhdcVZcnPOypOTE3lAF+2Zy+EAD4TmoW6pH2nLvB/Embnw89McTUnta6H uAIxt3HogobYqRXzNR0tqJCgrZxbcL3RjYMEWKpC0rZvEJppmxYQvamGRrMkz8WBzdrH WNCg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11si36939045pgg.554.2019.04.30.08.39.57; Tue, 30 Apr 2019 08:40:13 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726188AbfD3Phm (ORCPT + 99 others); Tue, 30 Apr 2019 11:37:42 -0400 Received: from mga14.intel.com ([192.55.52.115]:56135 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbfD3Phl (ORCPT ); Tue, 30 Apr 2019 11:37:41 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Apr 2019 08:37:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,414,1549958400"; d="scan'208";a="153608978" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.86]) by FMSMGA003.fm.intel.com with ESMTP; 30 Apr 2019 08:37:38 -0700 Received: from andy by smile with local (Exim 4.92) (envelope-from ) id 1hLUp6-0007FV-Ki; Tue, 30 Apr 2019 18:37:36 +0300 Date: Tue, 30 Apr 2019 18:37:36 +0300 From: Andy Shevchenko To: Esben Haabendal Cc: linux-serial@vger.kernel.org, Enrico Weigelt , Greg Kroah-Hartman , Jiri Slaby , Darwin Dingel , Jisheng Zhang , Sebastian Andrzej Siewior , He Zhe , Marek Vasut , Douglas Anderson , Paul Burton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] serial: 8250: Add support for using platform_device resources Message-ID: <20190430153736.GL9224@smile.fi.intel.com> References: <20190430140416.4707-1-esben@geanix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190430140416.4707-1-esben@geanix.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 30, 2019 at 04:04:13PM +0200, Esben Haabendal wrote: > Allow getting memory resource (mapbase or iobase) as well as irq from > platform_device resources. > > The UPF_DEV_RESOURCES flag must be set for devices where platform_device > resources are to be used. When not set, driver behaves as before. > > This allows use of the serial8250 driver together with devices with > resources added by platform_device_add_resources(), such as mfd child > devices added with mfd_add_devices(). > > Remaining platform_data fields (other than mapbase, iobase, mapsize and > irq) are used just as before. Note Note what? > +static int serial8250_probe_resources(struct platform_device *pdev, > + unsigned int num, > + struct plat_serial8250_port *p, > + struct uart_8250_port *uart) > +{ > + struct resource *r; > + int irq; > + > + switch (p->iotype) { > + case UPIO_AU: > + case UPIO_TSI: > + case UPIO_MEM32: > + case UPIO_MEM32BE: > + case UPIO_MEM16: > + case UPIO_MEM: > + r = platform_get_resource(pdev, IORESOURCE_MEM, num); > + if (!r) > + return -ENODEV; > + uart->port.mapbase = r->start; > + uart->port.mapsize = resource_size(r); > + uart->port.flags |= UPF_IOREMAP; > + break; > + case UPIO_HUB6: > + case UPIO_PORT: > + r = platform_get_resource(pdev, IORESOURCE_IO, num); > + if (!r) > + return -ENODEV; > + uart->port.iobase = r->start; > + uart->port.mapsize = resource_size(r); > + break; > + } > + > + irq = platform_get_irq(pdev, num); > + if (irq == -ENXIO) > + uart->port.irq = 0; /* no interrupt -> use polling */ > + else if (irq < 0) > + return irq; > + uart->port.irq = irq; > + > + return 0; > +} Hmm... Currently it's done inside individual port drivers, like 8250_dw.c. Each of the drivers can do it differently, for example 8250_lpss.c or 8250_pnp.c. > + if (!(port->flags & UPF_DEV_RESOURCES)) > + release_mem_region(port->mapbase, size); This is again same issue. The parent should not request resource it doesn't use. I think I understand what is a confusion here. For the IO resources we have two operations: - mapping / re-mapping (may be shared) - requesting (exclusive) In the parenthesis I put a level of access to it. While many device drivers can *share* same resource (mapped or unmapped), the only one can actually request it. So, the parent can take an slice resources as it would be appropriated, but not requesting them. OTOH, it's possible to have a (weird) MFD case where parent *requested* resources, and *all* of its children are aware of that. -- With Best Regards, Andy Shevchenko