Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7461153rwb; Mon, 12 Dec 2022 15:10:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf7p0+lOU4WhKsExxCYLOq9EP2iruXA8t4NqZhRUL9a6miaGIsW3fAWRBw2uyeQ0nJaFdFMa X-Received: by 2002:a05:6a00:1a42:b0:572:4ea8:30b9 with SMTP id h2-20020a056a001a4200b005724ea830b9mr22903941pfv.15.1670886632827; Mon, 12 Dec 2022 15:10:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670886632; cv=none; d=google.com; s=arc-20160816; b=P6FrPVSDgvI5uHhDZ8URzRA4B3Dtz2Yal2OPHMudl3oazj6iVLWx/A2CWs3MEh/LPD Aq8DZQKWornU6yjoXGFK1cezQb9t0F941G9iKzfXRtirMSM4xLcMMn0hOulQ1dBPwd6i OLCEIv9gRJw/OAfjK1BKy/YibGosKUbfxannwbk9xfw2R6YqSGEPt/4zmP8hBVlZaHb+ WJ5Yj5VUXuxp4FWYhdqlM9GzCrHqHTM/k605ko0jUvKEBWa5JtzwrnhG+SxGl0nDOjZn bwkqJpopfNBF84C+wZHIncfBrqiDSK63Dz2JX4vsaLeks08GOHCJ49+mGpby5l6nf6T2 C5Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:content-disposition :content-transfer-encoding:mime-version:in-reply-to:references:cc :user-agent:date:subject:to:from; bh=wkIDoS4ne3bzCtG+3PvAkWwleJi3lIRn76tTOYWSMw4=; b=aP1DoFelvrqxgj7eH47Ga/F4jX4HdmkjxLqUSmin+aCIBNbQy3wnUz4t9ra+rav+tf NJHORyf7Jg4BDWzC2vGbMOo5MImvpAxCTI+P4eScti/kAq7LAjkIAP0OGqdpLNB8TJDj SmIyjTBSOksmIn8gVwbvyovBA9F5+3fOzhs/rrvtOiGfZlhuBJX1o1SoNMUyrV8LsLOu XAc9wfIbFGBYaXN0W5dWonRgSTb/E4KRhu5DLAFeDm/MEp/LLDgHdvK0GIu+XWTXkvWj QcBXHSSVC6+ub265O6QKKvL5+xMot6oR4p6N91mhjBDw9I6yze//fDfCzoo/Y6aCuN2y eXFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c15-20020aa7880f000000b005775394c99fsi10603065pfo.52.2022.12.12.15.10.23; Mon, 12 Dec 2022 15:10:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229653AbiLLWzn (ORCPT + 75 others); Mon, 12 Dec 2022 17:55:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233737AbiLLWzh (ORCPT ); Mon, 12 Dec 2022 17:55:37 -0500 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 46D5D1208B; Mon, 12 Dec 2022 14:55:36 -0800 (PST) Received: from [192.168.0.2] (chello089173232159.chello.sk [89.173.232.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by hosting.gsystem.sk (Postfix) with ESMTPSA id EF74A7A028B; Mon, 12 Dec 2022 23:55:33 +0100 (CET) From: Ondrej Zary To: Damien Le Moal Subject: Re: [PATCH] pata_parport: add driver (PARIDE replacement) Date: Mon, 12 Dec 2022 23:55:30 +0100 User-Agent: KMail/1.9.10 Cc: Christoph Hellwig , Sergey Shtylyov , Jens Axboe , Tim Waugh , linux-block@vger.kernel.org, linux-parport@lists.infradead.org, linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220312144415.20010-1-linux@zary.sk> <202211151556.52895.linux@zary.sk> In-Reply-To: X-KMail-QuotePrefix: > MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <202212122355.30988.linux@zary.sk> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday 16 November 2022 02:30:46 Damien Le Moal wrote: > On 2022/11/15 23:56, Ondrej Zary wrote: > > On Tuesday 15 November 2022, Damien Le Moal wrote: > >> On 11/15/22 04:25, Ondrej Zary wrote: > >>> On Monday 14 November 2022 09:03:28 Damien Le Moal wrote: > >>>> On 11/14/22 16:53, Ondrej Zary wrote: > >>>>> On Monday 14 November 2022, Damien Le Moal wrote: > >>>>>> On 11/12/22 20:17, Ondrej Zary wrote: > >>>>>>> On Wednesday 19 October 2022 09:34:31 Christoph Hellwig wrote: > >>>>>>>> It's been a while - did you get a chance to make some progress on > >>>>>>>> this? Do you need any help to unblock you? > >>>>>>>> > >>>>>>> > >>>>>>> Sorry again, I'm back now. Trying to fix locking problems. > >>>>>>> Added this to each function for analysis how the functions are called wrt. > >>>>>>> locking: > >>>>>>> > >>>>>>> printk("%s, locked=%d\n", __FUNCTION__, spin_is_locked(ap->lock)); > >>>>>> > >>>>>> Do you have your code somewhere that we can look at ? > >>>>> > >>>>> This is the current version with debug printks. I've also added dump_stack() > >>>>> to find out the code path but haven't analyzed the output yet. > >>>> > >>>> Can you send a proper patch ? Or a link to a git tree ? That is easier to > >>>> handle than pasted code in an email... > >>> > >>> Patch against what? I don't have a git server. > >> > >> patch against current 6.1-rc, or against an older kernel should be OK too. > >> But please "git send-email" a patch, or push your dev tree to github ? > >> > >>> I've done some call trace analysis. These code paths are calling > >>> pata_parport functions with ap->lock locked during init. > >>> > >>> Comm: kworker, Workqueue: ata_sff ata_sff_pio_task > >>> ata_sff_hsm_move -> ata_pio_sectors-> ata_sff_altstatus -> pata_parport_tf_read -> pata_parport_check_altstatus > >>> ata_sff_hsm_move -> ata_sff_altstatus -> pata_parport_tf_read -> pata_parport_check_altstatus > >>> ata_sff_pio_task -> ata_sff_busy_wait -> pata_parport_check_status > >>> ata_sff_hsm_move -> ata_wait_idle -> ata_sff_busy_wait -> pata_parport_check_status > >>> ata_sff_hsm_move -> ata_hsm_qc_complete -> ata_sff_irq_on -> ata_wait_idle -> ata_sff_busy_wait -> pata_parport_check_status > >>> ata_sff_pio_task -> ata_sff_hsm_move -> ata_pio_sectors -> ata_pio_sector -> ata_pio_xfer -> pata_parport_data_xfer > >>> ata_sff_pio_task -> ata_sff_hsm_move -> pata_parport_data_xfer > >>> ata_sff_pio_task -> ata_sff_hsm_move -> pata_parport_tf_read > >>> ata_sff_hsm_move -> ata_hsm_qc_complete -> ata_qc_complete -> fill_result_tf -> ata_sff_qc_fill_rtf -> pata_parport_tf_read > >>> ata_sff_hsm_move -> ata_pio_sectors -> ata_sff_altstatus -> pata_parport_check_altstatus > >>> ata_sff_hsm_move -> ata_sff_altstatus -> pata_parport_check_altstatus > >>> > >>> Comm: modprobe > >>> ata_host_start -> ata_eh_freeze_port -> ata_sff_freeze -> pata_parport_check_status > >>> > >>> Comm: scsi_eh_4 > >>> ata_eh_recover -> ata_eh_reset -> ata_eh_thaw_port -> ata_sff_thaw -> ata_sff_irq_on -> ata_wait_idle -> ata_sff_busy_wait -> pata_parport_check_status > >>> ata_eh_reset -> ata_eh_freeze_port -> ata_sff_freeze -> pata_parport_check_status > >>> ata_scsi_error -> ata_scsi_port_error_handler -> ata_port_freeze -> ata_sff_freeze -> pata_parport_check_status > >>> ata_sff_error_handler -> pata_parport_drain_fifo -> pata_parport_check_status > >> > >> What exactly are the issues you are having with ap->lock ? It looks like > >> you have done a lot of analysis of the code, but without any context about > >> the problem, I do not understand what I am looking at. > >> > > > > The problem is that pi_connect() can sleep because it calls > > parport_claim_or_block(). And any access (even reading ATA status register) > > requires pi_connect. > > OK. Let me have a look. > The locking problems seem not to be easily solvable. Maybe a hack that grabs the parport before registering ata interface (and keeps it until the interface is disabled) will help? That will prevent multiple chained devices on one parport from working but can get pata_parport moving. -- Ondrej Zary