Linux-Crypto Archive on lore.kernel.org
 help / color / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: "Horia Geantă" <horia.geanta@nxp.com>
Cc: Aymen Sghaier <aymen.sghaier@nxp.com>,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: set_cpus_allowed_ptr() usage in FREESCALE CAAM
Date: Fri, 5 Oct 2018 14:54:44 +0200
Message-ID: <20181005125443.dfhd2asqktm22ney@linutronix.de> (raw)

Hi,

this block:
|int caam_qi_shutdown(struct device *qidev)
| {
|         struct cpumask old_cpumask = current->cpus_allowed;
…
|         /*
|          * QMan driver requires CGRs to be deleted from same CPU from where they
|          * were instantiated. Hence we get the module removal execute from the
|          * same CPU from where it was originally inserted.
|          */
|         set_cpus_allowed_ptr(current, get_cpu_mask(mod_init_cpu));
…
|          /* Now that we're done with the CGRs, restore the cpus allowed mask */
|         set_cpus_allowed_ptr(current, &old_cpumask);

in drivers/crypto/caam/qi.c needs to go. I saw it twice in the driver.
set_cpus_allowed_ptr() is not intended for this kind of thing.

What you want is to use work_on_cpu_safe() instead. It takes also a CPU
as an argument. You need to check the error code of the function if it
worked because the CPU may have gone offline. This functions also
ensures that the CPU does not vanish in the middle of the work. 
Also please check the error code in both cases of the function because
it may fail if the CPU is not online.

Sebastian

             reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-05 12:54 Sebastian Andrzej Siewior [this message]
2018-10-08 11:09 ` [PATCH] crypto: caam/qi - simplify CGR allocation, freeing Horia Geantă
2018-10-09 17:11   ` Sebastian Andrzej Siewior
2018-10-25 14:05     ` Horia Geanta
2018-10-29  8:56       ` Sebastian Andrzej Siewior
2018-10-17  6:21   ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181005125443.dfhd2asqktm22ney@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=aymen.sghaier@nxp.com \
    --cc=horia.geanta@nxp.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Crypto Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-crypto/0 linux-crypto/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-crypto linux-crypto/ https://lore.kernel.org/linux-crypto \
		linux-crypto@vger.kernel.org
	public-inbox-index linux-crypto

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-crypto


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git